Purpose of the Library

Provide useful routines  for working with cpusets (on ALTX systems) and/or their Fortran interfaces

Location of the Library    

/lrz/sys/lib/liblrz_cpuset.a

Header files

/lrz/sys/include/lrz_cpuset.h
/lrz/sys/include/lrz_cpuset_f.h  (for Fortran)

Compilation

module load liblrz
icc/ifort ...  $LIBLRZ_CPUSET_INC $LIBLRZ_CPUSET_LIB


Content of the lib

int cpuset_size();
INTEGER CPUSET_SIZE()

Return the number of CPUs in the current tasks cpuset. The relative CPU numbers that are passed to the cpuset_pin() function and that are returned by the cpuset_where() function, must be between 0 and N - 1 inclusive, where N is the value returned by cpuset_size().

int cpuset_where();
INTEGER CPUSET_WHERE()

Return the CPU number, relative to the current tasks cpuset, of the CPU on which the current task most recently executed. If a task is allowed to execute on more than one CPU, then there is no guarantee that the task is still executing on the CPU returned by cpuset_where, by the time that the user code obtains the return value.

int cpuset_pin(int relcpu);
INTEGER CPUSET_PIN(relcpu)
    integer relcpu

Pin the current task to execute only on the CPU relcpu, which is a relative CPU number within the current cpuset of that task. Also automatically pin the memory allowed to be used by the current task to the memory on that same node.

Example:

call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world,myrank,ierr)
call mpi_comm_size(mpi_comm_world,mysize,ierr)

!$omp parallel
    ithreads=omp_get_num_threads()
!$omp end parallel

!$omp parallel do ordered private(j,ierr)
do j=0,ithreads-1
     Ierr=cpuset_pin(myrank*ithreads+j)
enddo

int cpuset_unpin();
INTEGER CPUSET_UNPIN()

Remove the CPU and Memory pinning affects of any previous cpuset_pin call, allowing the current task to execute on any CPU in its current cpuset and to allocate memory on any Memory Node in its current cpuset.

integer gettid(void) 
integer getlwp(void) 
INTEGER GETTID()
INTEGER GETLWP()

gettid() returns the thread ID (light weight process, or thread) of the current process. This is equal to the process ID (as returned by getpid(2)), unless the process is part of a thread group (created by specifying the CLONE_THREAD flag to the clone(2) system call). All processes in the same thread group have the same PID, but each one has a unique TID.

int where_do_i_run()
INTEGER WHERE_DO_I_RUN()

Return the ab solute CPU number, which the current task most recently executed.

int where_can_i_run(int *len, int cpumask[])
INTEGER WHERE_CAN_I_RUN(len,cpumask)
            integer len, cpumask(len)

Return the absolute CPU on which a thread can run. If more than one CPU is possible, the negatvie number of the highest possible CPU is returned. also a cpumask, containing 0 and 1, is returned, showing on which CPUs a thread may execute. len is the dimension of the cpu_mask, i.e. the number of processors in a partition.