libparanut
A Hardware Abstraction Layer for ParaNut Architectures.

Functions for using the linked mode. More...

Collaboration diagram for Link Module:
PN_CID pn_begin_linked_gm (PN_CMSK *coremask_array, PN_NUMG array_size, char flags)
 
int pn_end_linked (void)
 Ends linked execution. More...
 
PN_CID pn_run_linked_gm (PN_CMSK *coremask_array, PN_NUMG array_size, void *function, void *args)
 NOT IMPLEMENTED YET, run a function in linked mode using group mask. More...
 
PN_CID pn_run_linked (PN_NUMC numcores, void(*func)(), void *args)
 Starts a given function in linked mode. More...
 
#define PN_BEGIN_LINKED(NUMCORES)
 Call pn_begin_linked with the __buitlin_frame_address(0). More...
 
#define PN_BEGIN_LINKED_M(COREMASK)
 Call pn_begin_linked_m with the __buitlin_frame_address(0). More...
 
#define PN_END_LINKED()   pn_end_linked()
 Call pn_end_linked. More...
 
#define PN_BEGIN_LINKED(NUMCORES)
 Call pn_begin_linked with the __buitlin_frame_address(0). More...
 
#define PN_BEGIN_LINKED_M(COREMASK)
 Call pn_begin_linked_m with the __buitlin_frame_address(0). More...
 
#define PN_END_LINKED()   pn_end_linked()
 Call pn_end_linked. More...
 

Detailed Description

Functions for using the linked mode.

Also see Modes.

Warning
If you want to use the Linked Module on RISC-V ParaNut, your ParaNut has to support the M Extension and you have to compile your application with the flag mabi=rv32im. The libparanut Makefile sets this flag automatically when you chose the Link Module or one of the Modules that has Link Module as a dependency.

Macro Definition Documentation

◆ PN_BEGIN_LINKED [1/2]

#define PN_BEGIN_LINKED (   NUMCORES)
Value:
({ \
char flags = 0; \
void *frame_addr = __builtin_frame_address(0); \
void *fp = NULL; \
asm volatile("mv %0, s0" : "=r" (fp)); \
if(fp == frame_addr){ \
flags = 1; \
} \
pn_begin_linked(NUMCORES, __builtin_frame_address(0), flags);})

Call pn_begin_linked with the __buitlin_frame_address(0).

Calls pn_begin_linked with the gcc built-in function __buitlin_frame_address(0) to copy only the current stack frame.

◆ PN_BEGIN_LINKED [2/2]

#define PN_BEGIN_LINKED (   NUMCORES)
Value:
({ \
char flags = 0; \
void *frame_addr = __builtin_frame_address(0); \
void *fp = NULL; \
asm volatile("mv %0, s0" : "=r" (fp)); \
if(fp == frame_addr){ \
flags = 1; \
} \
pn_begin_linked(NUMCORES, __builtin_frame_address(0), flags);})

Call pn_begin_linked with the __buitlin_frame_address(0).

Calls pn_begin_linked with the gcc built-in function __buitlin_frame_address(0) to copy only the current stack frame.

◆ PN_BEGIN_LINKED_M [1/2]

#define PN_BEGIN_LINKED_M (   COREMASK)
Value:
char flags = 0; \
void *frame_addr = __builtin_frame_address(0); \
void *fp = NULL; \
asm volatile("mv %0, s0" : "=r" (fp)); \
if(fp == frame_addr){ \
flags = 1; \
} \
pn_begin_linked_m(COREMASK, __builtin_frame_address(0), flags)

Call pn_begin_linked_m with the __buitlin_frame_address(0).

Calls pn_begin_linked_m with the gcc built-in function __buitlin_frame_address(0) to copy only the current stack frame.

◆ PN_BEGIN_LINKED_M [2/2]

#define PN_BEGIN_LINKED_M (   COREMASK)
Value:
char flags = 0; \
void *frame_addr = __builtin_frame_address(0); \
void *fp = NULL; \
asm volatile("mv %0, s0" : "=r" (fp)); \
if(fp == frame_addr){ \
flags = 1; \
} \
pn_begin_linked_m(COREMASK, __builtin_frame_address(0), flags)

Call pn_begin_linked_m with the __buitlin_frame_address(0).

Calls pn_begin_linked_m with the gcc built-in function __buitlin_frame_address(0) to copy only the current stack frame.

◆ PN_END_LINKED [1/2]

#define PN_END_LINKED ( )    pn_end_linked()

Call pn_end_linked.

Calls pn_end_linked. Is only defined to have aesthetically matching pair with the PN_BEGIN_LINKED and PN_BEGIN_LINKED_M macros.

◆ PN_END_LINKED [2/2]

#define PN_END_LINKED ( )    pn_end_linked()

Call pn_end_linked.

Calls pn_end_linked. Is only defined to have aesthetically matching pair with the PN_BEGIN_LINKED and PN_BEGIN_LINKED_M macros.

Function Documentation

◆ pn_begin_linked_gm()

PN_CID pn_begin_linked_gm ( PN_CMSK coremask_array,
PN_NUMG  array_size,
char  flags 
)

◆ pn_end_linked()

int pn_end_linked ( void  )

Ends linked execution.

Halts all CoPUs that are currently linked together, effectively ending the linked execution. Will fail if there are no cores linked together.

See documentation of Modes for more information.

Can be executed on CoPU, but will do nothing then.

Returns
Either PN_SUCCESS or PN_ERR_MATCH.

◆ pn_run_linked()

PN_CID pn_run_linked ( PN_NUMC  numcores,
void(*)()  func,
void *  args 
)

Starts a given function in linked mode.

Todo:
Not yet implemented for more cores than what is available in one group. Will return PN_ERR_NOIMP when called with more cores.

Sets numcores-1 CoPUs to Mode 1 (linked Mode) and runs the given function. After completing the function will return 0 in case of success. This function will return an error (PN_ERR_MATCH) if the CoPUs are not all halted. The referenced function should have two attributes: void *args, PN_CID cid. Argument 1 is defined by the user, while argument 2 "cid" contains the ID of the executing Core.

Cannot be executed on CoPU. Cannot be mixed with threaded mode or other linked mode functions, until pn_end_linked() is called.

Attention
All data that you want to preserve after completing the function has returned can not be stored on stack. You can make it static or global.
Warning
There is no guarantee that the execution of code actually happens at the same time on CePUs and CoPUs.
Parameters
[in]numcoresis the number of cores that shall be linked together. A value of 0 or 1 will return an error (PN_ERR_PARAM) to aid debugging.
[in]funcfunctionpointer to the function to be executed in linked mode. The function may expect a single argument in the form of a void pointer. Will return PN_ERR_PARAM if NULL.
[in]argscontains the void pointer to be handed to the function. May also be NULL.
Returns
PN_SUCCESS, PN_ERR_MATCH, PN_ERR_PARAM, or PN_ERR_COPU.
Todo:
Not yet implemented for more cores than what is available in one group. Will return PN_ERR_NOIMP when called with more cores.

Sets numcores-1 CoPUs to Mode 1 (linked Mode) and runs the given function. After completing the function will return 0 in case of success. This function will return an error (PN_ERR_MATCH) if the CoPUs are not all halted. The referenced function should have two attributes: void *args, PN_CID cid. Argument 1 is defined by the user, while argument 2 "cid" contains the ID of the executing Core.

Cannot be executed on CoPU. Cannot be mixed with threaded mode or other linked mode functions, until pn_end_linked() is called.

Attention
All data that you want to preserve after completing the function has returned can not be stored on stack. You can make it static or global.
Warning
There is no guarantee that the execution of code actually happens at the same time on CePUs and CoPUs.
Parameters
[in]numcoresis the number of cores that shall be linked together. A value of 0 or 1 will return an error (PN_ERR_PARAM) to aid debugging.
[in]funcfunctionpointer to the function to be executed in linked mode. The function may expect a single argument in the form of a void pointer. Will return PN_ERR_PARAM if NULL.
[in]argscontains the void pointer to be handed to the function. May also be NULL.
Returns
PN_SUCCESS, PN_ERR_MATCH, PN_ERR_PARAM, or PN_ERR_COPU.

◆ pn_run_linked_gm()

PN_CID pn_run_linked_gm ( PN_CMSK coremask_array,
PN_NUMG  array_size,
void *  function,
void *  args 
)

NOT IMPLEMENTED YET, run a function in linked mode using group mask.

Todo:
Currently only a stub. Will therefore always return PN_ERR_NOIMP.
Todo:
Currently only a stub. Will therefore always return PN_ERR_NOIMP.