Dear concern,
Please consider the source code(openmp c code) snippet as below:
— code snippet —
int a1, b1, c1, N;
Initially address of a1:= 0x7fff9bd58304
omp_set_num_threads(2);
#pragma omp parallel
{
#pragma omp single
{
// task one: a1=b1+c1;
#pragma omp task shared(a1) firstprivate(b1,c1)
{
a1 = a1 + b1 + c1;
}
}
}
In the above openMP code task construct contains shared variable (a1), I AM INTERESTED TO FIND THE SHARED VARIABLE OF TASK DATA IN RUNTIME TASK ALLOCATION.
I am looking into the source code of Intel OpenMP Runtime, my openmp code is compiled with LLVM. In the LLVM IR, @__kmpc_omp_task_alloc( …) calls runtime function kmp_task_alloc(), source code is here: under the directory, Kmp_tasking.c
I am trying to access the “shared variable data location for a task” which is as below:
kmp_task_t *
__kmp_task_alloc(…){
kmp_task_t *task;
kmp_taskdata_t *taskdata;
// Calculate shared structure offset including padding after kmp_task_t struct
// to align pointers in shared struct
shareds_offset = sizeof( kmp_taskdata_t ) + sizeof_kmp_task_t;
shareds_offset = __kmp_round_up_to_val( shareds_offset, sizeof( void * ));
// Avoid double allocation here by combining shareds with taskdata
#if USE_FAST_MEMORY
taskdata = (kmp_taskdata_t ) __kmp_fast_allocate( thread, shareds_offset + sizeof_shareds );
#else / ! USE_FAST_MEMORY */
taskdata = (kmp_taskdata_t ) __kmp_thread_malloc( thread, shareds_offset + sizeof_shareds );
#endif / USE_FAST_MEMORY */
task = KMP_TASKDATA_TO_TASK(taskdata);
if (sizeof_shareds > 0) {
// Avoid double allocation here by combining shareds with taskdata
task->shareds = & ((char *) taskdata)[ shareds_offset ];
printf(“task->shareds address original:= %p address of pointer it points to := %p\n”, & ((char *) taskdata)[ shareds_offset ], *task->shareds);
}
}
here,
typedef struct kmp_task { /* GEH: Shouldn’t this be aligned somehow? */
void * shareds; /**< pointer to block of pointers to shared vars */
}
But, task->shareds = & ((char *) taskdata)[ shareds_offset ]; which is a pointer to block of pointers to shared variables, if I print the shared variable pointing address(which should be the address of a1:= 0x7fff9bd58304)
IT PRINTS DIFFERENT ADDRESS: <0x1fe0ef0>
NEED TO GET THE ADDRESS OF TASK’S SHARED VARIABLE ADDRESS FROM RUNTIME.
appreciate your comment and help. Thanking you.