MPC_Common

Module MPC_Common

SUMMARY:

This module contains all basic blocks of MPC framework, common to other modules.

CONTENTS:

  • sctk_optim/ : longjmp/setjmp (may be moved)

  • sctk_alloc/ : POSIX binding when allocator is disabled

  • sctk_asm/ : ASM part of MPC (test_and_set, atomics)

  • sctk_debug/ : Debug interface definition (assert…)

  • libdict/ :

  • sctk_launch/ : MPC start definition (main())

  • sctk_datastructures/ : third-party data-structure (UT*)

  • sctk_basic/ : Misc. (stdint..)

  • sctk_aio/ :

  • sctk_topology/ : hardware topology management

  • sctk_spinlock/ : lock interfaces for MPC

  • sctk_helpers/ : MPC helpers (net,I/O…)

COMPONENTS:

LIBC & Main() interposition

One challenge for MPC is to replace the application main() function by its own. Up to now, MPC needed to be compiled with the application, a macro was in charge or renaming main symbol to mpc_user_main. The idea is to provide a way to replace at runtime the main symbol with needing a recompilation.

As the main symbol cannot be overridden because its address is hard-written in the start function, pre-compiled in crt1.o, file appended when the application is linked. the use of LD_PRELOAD is useless. But among other program loading sequence function, one can be overridden because not contained in the binary. __libc_start_main is a loader function (that is why it is not included in the binary) and holds as first argument, the pointer to the main function (actually transmitted by _start). The idea of sctk_launch/mpc_libc_main.c is to override this function by preloading a standalone library (built with MPC).

The library attempts to detect if the current program should be wrapped with MPC. This has to be done, avoiding MPC to be loaded in each program started between the command-line and the application (don’t wrap grep, ls, cd…). There is two ways to elect a program:

  1. The user specifies through MPC_USER_BINARY the name of the binary to wrap. For example: MPC_USER_BINARY="a.out" mpcrun ./a.out will work.

  2. The user defines a pattern of function that should be present in the wrapped binary. This can be performed with MPC_SYMBOL_REGEX, accepting any kind of regular expressions grep can use. For example: MPC_SYMBOL_REGEX="MPI_Init" mpcrun ./mpi_helloworld

API

group MPC_Common

This module is in charge of providing ranks and count for the whole MPC.

This is the interface to query ranks and count.

Functions

static inline int mpc_common_get_process_count(void)

Get the number of UNIX processes.

Returns:

int Number of UNIX processes

static inline int mpc_common_get_process_rank(void)

Get the rank for current UNIX process.

Returns:

int rank of current UNIX process

static inline int mpc_common_get_local_process_count(void)

Get the number of local UNIX processes (on same NONE)

Returns:

int number of local processes

static inline int mpc_common_get_local_process_rank(void)

Get the rank in local UNIX processes for current process.

Returns:

int rank for current process in local UNIX processes

static inline int mpc_common_get_node_count(void)

Get node count.

Returns:

int node count

static inline int mpc_common_get_node_rank(void)

Get node rank for current process.

Returns:

int node rank

Variables

int __process_count

Global variables storing process count.

int __process_rank

Global variable storing process rank.

int __process_app_rank

Global variable storing app rank.

int __local_process_count

Storage for the number of local UNIX processes.

int __local_process_rank

Storage for the rank of local UNUX process.

int __node_count

Storage for node count.

int __node_rank

Storage for node rank.

These are the generic task rank and count getters when MPC_Threads is not available.

Functions

static inline int mpc_common_get_app_rank()
static inline void mpc_common_set_app_rank(int app_rank)
static inline int mpc_common_get_app_size()
static inline int mpc_common_get_app_num()
static inline int mpc_common_get_app_count()
static inline int mpc_common_get_task_count(void)

Get task count in current UNIX process.

Returns:

int task count

static inline int mpc_common_get_task_rank(void)

Get the task rank for current thread.

Returns:

int task rank

static inline int mpc_common_get_local_task_count(void)

Get the number of tasks in current process.

Returns:

int number of tasks on node

static inline int mpc_common_get_local_task_rank(void)

Get the task rank of given thread in current process.

Returns:

int task rank on node

static inline int mpc_common_get_thread_id(void)

Return the thread id for current thread (only when in MPC threads) returns the PID otherwise.

Returns:

int thread id when in MPC’s scheduler (PID otherwise)

Initialization modules use these functions to set ranks.

Functions

void mpc_common_set_process_count(int process_count)

Set the number of UNIX processes.

Parameters:
  • process_count – Number of UNIX processes to set

void mpc_common_set_process_rank(int process_rank)

Set the UNIX process rank.

Parameters:
  • process_rank – the unix process rank to set

void mpc_common_set_local_process_count(int local_process_count)

Set the number of local UNIX process (on same NODE)

Parameters:
  • local_process_count – number of UNIX processes on node

void mpc_common_set_local_process_rank(int local_process_rank)

Set the local rank for UNIX process (on same NONE)

Parameters:
  • local_process_rank – on node rank for UNIX process

void mpc_common_set_node_count(int node_count)

Set the number of nodes.

Parameters:
  • node_count – number of nodes

void mpc_common_set_node_rank(int node_rank)

The the node rank for current UNIX process.

Parameters:
  • node_rank – node rank

This is the interface to query ranks and count.

Functions

static inline int mpc_common_get_process_count(void)

Get the number of UNIX processes.

Returns:

int Number of UNIX processes

static inline int mpc_common_get_process_rank(void)

Get the rank for current UNIX process.

Returns:

int rank of current UNIX process

static inline int mpc_common_get_local_process_count(void)

Get the number of local UNIX processes (on same NONE)

Returns:

int number of local processes

static inline int mpc_common_get_local_process_rank(void)

Get the rank in local UNIX processes for current process.

Returns:

int rank for current process in local UNIX processes

static inline int mpc_common_get_node_count(void)

Get node count.

Returns:

int node count

static inline int mpc_common_get_node_rank(void)

Get node rank for current process.

Returns:

int node rank

Variables

int __process_count

Global variables storing process count.

int __process_rank

Global variable storing process rank.

int __process_app_rank

Global variable storing app rank.

int __local_process_count

Storage for the number of local UNIX processes.

int __local_process_rank

Storage for the rank of local UNUX process.

int __node_count

Storage for node count.

int __node_rank

Storage for node rank.

These are the generic task rank and count getters when MPC_Threads is not available.

Functions

static inline int mpc_common_get_app_rank()
static inline void mpc_common_set_app_rank(int app_rank)
static inline int mpc_common_get_app_size()
static inline int mpc_common_get_app_num()
static inline int mpc_common_get_app_count()
static inline int mpc_common_get_task_count(void)

Get task count in current UNIX process.

Returns:

int task count

static inline int mpc_common_get_task_rank(void)

Get the task rank for current thread.

Returns:

int task rank

static inline int mpc_common_get_local_task_count(void)

Get the number of tasks in current process.

Returns:

int number of tasks on node

static inline int mpc_common_get_local_task_rank(void)

Get the task rank of given thread in current process.

Returns:

int task rank on node

static inline int mpc_common_get_thread_id(void)

Return the thread id for current thread (only when in MPC threads) returns the PID otherwise.

Returns:

int thread id when in MPC’s scheduler (PID otherwise)

These are the generic task rank and count getters when MPC_Threads is not available.

Functions

static inline int mpc_common_get_app_rank()
static inline void mpc_common_set_app_rank(int app_rank)
static inline int mpc_common_get_app_size()
static inline int mpc_common_get_app_num()
static inline int mpc_common_get_app_count()
static inline int mpc_common_get_task_count(void)

Get task count in current UNIX process.

Returns:

int task count

static inline int mpc_common_get_task_rank(void)

Get the task rank for current thread.

Returns:

int task rank

static inline int mpc_common_get_local_task_count(void)

Get the number of tasks in current process.

Returns:

int number of tasks on node

static inline int mpc_common_get_local_task_rank(void)

Get the task rank of given thread in current process.

Returns:

int task rank on node

static inline int mpc_common_get_thread_id(void)

Return the thread id for current thread (only when in MPC threads) returns the PID otherwise.

Returns:

int thread id when in MPC’s scheduler (PID otherwise)

Initialization modules use these functions to set ranks.

Functions

void mpc_common_set_process_count(int process_count)

Set the number of UNIX processes.

Parameters:
  • process_count – Number of UNIX processes to set

void mpc_common_set_process_rank(int process_rank)

Set the UNIX process rank.

Parameters:
  • process_rank – the unix process rank to set

void mpc_common_set_local_process_count(int local_process_count)

Set the number of local UNIX process (on same NODE)

Parameters:
  • local_process_count – number of UNIX processes on node

void mpc_common_set_local_process_rank(int local_process_rank)

Set the local rank for UNIX process (on same NONE)

Parameters:
  • local_process_rank – on node rank for UNIX process

void mpc_common_set_node_count(int node_count)

Set the number of nodes.

Parameters:
  • node_count – number of nodes

void mpc_common_set_node_rank(int node_rank)

The the node rank for current UNIX process.

Parameters:
  • node_rank – node rank