System information

Intel® Xeon Phi Coprocessor DEVELOPERS QUICK START GUIDE
21
Code Example 4: Using the “_Cilk_shared” and “_Cilk_offload” Keywords with Dynamic Allocation in
C/C++
Note: For more examples on using the implicit memory copy model, see:
C: /opt/intel/composerxe/Samples/en_US/C++/mic_samples/shrd_sampleC
and …/LEO_tutorial
C++: /opt/intel/composerxe/Samples/en_US/C++/mic_samples/shrd_sampleCPP
For more information, users are encouraged to read the Intel C++ Compiler User and Reference Guides and/or
the Intel Fortran Compiler User and Reference Guides.
The section “Restrictions on Offload Using Shared Virtual Memory” in the document “Intel C++ Compiler User
and Reference Guide” shows some restrictions of using this programming model.
Native Compilation
Applications can also be run natively on the Intel® Xeon Phi™ Coprocessor, in which case the coprocessor will
be treated as a standalone multicore computer. Once the binary is built on the host system, copy the binary
and other related binaries or data to the Intel® Xeon Phi™ Coprocessor’s filesystem (or make them visible over
there via NFS).
Example:
1. Copy openmp_sample.c from
/opt/intel/composerxe/Samples/en_US/C++/openmp_samples/ to your home directory
2. Build the application with the mmic flag:
icc mmic vec-report3 openmp openmp_sample.c
3. Upload the binary to the coprocessor:
scp a.out mic0:/tmp/a.out
4. Copy over any shared libraries required by your application, in this case the OpenMP* runtime library:
scp /opt/intel/composerxe/lib/mic/libiomp5.so mic0:/tmp/libiomp5.so
5. Connect to the coprocessor with ssh and export the local directory so that the application can find any
shared libraries it uses (in this case the OpenMP* runtime library):
ssh mic0
export LD_LIBRARY_PATH=/tmp
6. This application may generate a segmentation fault if the stacksize is not set correctly. To modify the
stacksize use: