Intel® C++ Compiler 16.0 User and Reference Guide

Rules for Using _Cilk_shared and _Cilk_offload

This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

Follow these rules for using _Cilk_shared and _Cilk_offload for correct execution. In most cases the compiler issues diagnostics for incorrect usage.

Correct and Permitted Usage

Incorrect and Non-permitted Usage

Example

This example demonstrates incorrect usage of _Cilk_shared. The code attempts to declare a _Cilk_shared object, mark, local to a function.

#pragma offload_attribute(push, _Cilk_shared)
#include <vector>
#include "tbb/concurrent_vector.h"
#pragma offload_attribute(pop, _Cilk_shared)

class _Cilk_shared Thing
{
public:
  Thing(void) { m_size = 100; }
  void work();
  int m_size;
};

void Thing::work() {
  _Cilk_shared std::vector<bool> mark(m_size); // Error
  tbb::concurrent_vector< std::pair<unsigned int, unsigned int> > m_hits(m_size);
}

In this example of correct usage, the object mark has been allocated statically, and its usage modified slightly.

#include <vector>
#include "tbb/concurrent_vector.h"

_Cilk_shared std::vector<bool> mark;
_Cilk_shared tbb::concurrent_vector< std::pair<unsigned int, unsigned int> > m_hits;

class _Cilk_shared Thing
{
public:
  Thing(void) { m_size = 100; }
  void work();
  int m_size;
};

void Thing::work() {
  mark.resize(m_size);
  m_hits.resize(m_size);
}