Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

Abstraction and Cilk_shared

Mark_S_7
Beginner
527 Views

Hi,

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

[cpp]

abstract_class * classp;

classp = new base_class();

[/cpp]

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

0 Kudos
1 Reply
Rajiv_D_Intel
Employee
527 Views

#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.

 

0 Kudos
Reply