can pthread natively run on Xeon phi?

can pthread natively run on Xeon phi?

i think pthread is a very natural model for shared memory application, can a pthread application natively run on xeon phi? say we map each thread in pthread to a phi hardware thread, so 244 threads in total

i see some documents mention it a little, but have no details, i really appreciate it if you can confirm this

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Simple answer: YES.

The Intel(r) Xeon Phi(tm) coprocessor is running a full Linux kernel and has pthread support. (Indeed, most of the parallel runtimes on the machine like OpenMP, TBB and Cilk are built on top of pthreads).

The simple way to do this is to buid a "native" executable (just add "-mmic" to the compilation flags for the Intel compilers in your make file), and run the executable on the card.

Thanks! Then can we control the thread affinity for pthreads? mapping threads to different cores

I see the KMP_AFFINITY introduced for openmp, does it work for pthreads as well? Thanks in advance!

Zitat:

James Cownie (Intel) schrieb:

Simple answer: YES.

The Intel(r) Xeon Phi(tm) coprocessor is running a full Linux kernel and has pthread support. (Indeed, most of the parallel runtimes on the machine like OpenMP, TBB and Cilk are built on top of pthreads).

The simple way to do this is to buid a "native" executable (just add "-mmic" to the compilation flags for the Intel compilers in your make file), and run the executable on the card.

Based on I know, KMP_AFFINITY environment variable cannot be used with pthreads. The way to go about it would be the standard way using  pthread_setaffinity_np() or sched_setaffinty(). 

KMP_AFFINITY et al. are supported in the OpenMP library.  As the OpenMP for MIC is based on pthreads, this should provide a method for controlling pthread affinity, at the cost of linking the OpenMP library in the build (and presenting obstacles to use of Cilk+ or TBB in your application). You might invoke an OpenMP function such as omp_get_num_threads() to set up a thread pool with the affinity masks set by the KMP machinery.

pthreads are just that, the full, normal Linux pthread implementation. Therefore the normal mechanisms for handling affinity apply. (e.g.http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_setaffinity_np.3.html, http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_attr_setaffinity_np.3.html )

KMP_AFFINITY is specific to OpenMP, and, for MIC it's often better to use KMP_PLACE_THREADS, since that gives a simpler way to achieve the affinities you likely want.

As James implies, the OpenMP affinity methods should all be capable of duplication at the pthreads level, without requiring OpenMP library.

KMP_PLACE_THREADS was first documented in the current Intel compiler release (2013 update 2), and provides the most (or only) convenient way of affinitizing a given number of threads per core to a specified number of cores.  It still doesn't help in the case where multiple thread pools are to be set on different groups of cores.

Leave a Comment

Please sign in to add a comment. Not a member? Join today