Abstraction and Cilk_shared

Abstraction and Cilk_shared

Mark S.'s picture

Hi,

    Is there any way to use abstraction and _Cilk_shared. In normal C++ you can just do

abstract_class * classp;
classp = new base_class();

To use new using _Cilk_shared one must perform a vector to wrap the class as seen in http://software.intel.com/sites/default/files/article/326700/effective-use-of-compiler-features-for-offload.pdf at the end of page 14. However if the base class is abstract how does one do this as one cannot create a abstract class.

Cheers, Mark

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Rajiv Deodhar (Intel)'s picture

#pragma offload_attribute(push,_Cilk_shared)
#include "offload.h"
#pragma offload_attribute(pop)

class _Cilk_shared abstract_base_class {
 public:
  virtual void f() = 0;   // Pure virtual function.
};

class _Cilk_shared derived_class : public abstract_base_class
{
 public:
  virtual void f() {}
};

_Cilk_shared
void f()
{
        derived_class *p = (derived_class *)_Offload_shared_malloc(sizeof(derived_class));
        _Offload_shared_free(p);
}

}

The example above shows how to allocate and free objects using _Cilk_shared memory.

 

Login to leave a comment.