<div dir="ltr">Dear concern, <div><br></div><div>Please consider the source code(openmp c code) snippet as below: </div><div>--- code snippet ---</div><div>int a1, b1, c1, N;<br></div><div><div><br></div><div>Initially address of a1:= 0x7fff9bd58304 </div><div>omp_set_num_threads(2);</div><div><span class="" style="white-space:pre">   </span>#pragma omp parallel</div><div><span class="" style="white-space:pre">       </span>{</div><div><span class="" style="white-space:pre">  </span><span class="" style="white-space:pre">  </span>#pragma omp single</div><div><span class="" style="white-space:pre">         </span>{</div><div><span class="" style="white-space:pre">  </span><span class="" style="white-space:pre">          </span>// task one: a1=b1+c1;</div><div><span class="" style="white-space:pre">                     </span>#pragma omp task shared(a1) firstprivate(b1,c1)</div><div><span class="" style="white-space:pre">                    </span>{</div><div><span class="" style="white-space:pre">  </span><span class="" style="white-space:pre">                  </span>a1 = a1 + b1 + c1;</div><div><span class="" style="white-space:pre">                 }</span></div><div><span class="" style="white-space:pre">                 }</span></div><div><span class="" style="white-space:pre">         }</span></div><div><span class="" style="white-space:pre">    </span></div><div><span class="" style="white-space:pre">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.        </span></div></div><div><br></div><div>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 <src> directory, Kmp_tasking.c  </div><div><div><br></div><div><br></div><div>I am trying to access the "shared variable data location for a task" which is as below: </div><div><div>kmp_task_t *</div><div>__kmp_task_alloc(...){</div><div><div><br></div><div>kmp_task_t *task;</div><div>kmp_taskdata_t *taskdata;</div><div><br></div><div>// Calculate shared structure offset including padding after kmp_task_t struct</div><div>    // to align pointers in shared struct</div><div>    shareds_offset = sizeof( kmp_taskdata_t ) + sizeof_kmp_task_t;</div><div>    shareds_offset = __kmp_round_up_to_val( shareds_offset, sizeof( void * ));</div><div><br></div><div>// Avoid double allocation here by combining shareds with taskdata</div><div>    #if USE_FAST_MEMORY</div><div>    taskdata = (kmp_taskdata_t *) __kmp_fast_allocate( thread, shareds_offset + sizeof_shareds );</div><div>    #else /* ! USE_FAST_MEMORY */</div><div>    taskdata = (kmp_taskdata_t *) __kmp_thread_malloc( thread, shareds_offset + sizeof_shareds );</div><div>    #endif /* USE_FAST_MEMORY */</div><div>    </div></div><div>task                      = KMP_TASKDATA_TO_TASK(taskdata);<br></div><div><br></div><div><div>if (sizeof_shareds > 0) {</div><div>        // Avoid double allocation here by combining shareds with taskdata</div><div>        task->shareds         = & ((char *) taskdata)[ shareds_offset ];</div><div><span class="" style="white-space:pre"> printf("task->shareds address original:= %p  address of pointer it points to := %p\n", & ((char *) taskdata)[ shareds_offset ], *task->shareds);
                </span></div><div><span class="" style="white-space:pre">   }</span></div></div><div>}</div></div><div><br></div><div>here, </div><div>typedef struct kmp_task {                   /* GEH: Shouldn't this be aligned somehow? */</div><div>    void *              shareds;            /**< pointer to block of pointers to shared vars   */</div><div>}</div><div><br></div><div>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) </div><div>IT PRINTS DIFFERENT ADDRESS: <0x1fe0ef0></div><div><br></div><div>NEED TO GET THE ADDRESS OF TASK'S SHARED VARIABLE ADDRESS FROM RUNTIME.</div><div><br></div><div>appreciate your comment and help.  Thanking you.</div><div class="gmail_signature"><div dir="ltr"><div><font face="times new roman, serif" size="2" color="#cccccc">------------------------</font></div><font face="times new roman, serif" size="2" color="#999999">RaJu, Rezaul Karim<br>Graduate Student (PhD) | Computer Science | University of Houston</font><div><font face="times new roman, serif" size="2" color="#999999">Research in High Performance Computing Tools  </font><div><div><font face="times new roman, serif" size="2" color="#999999">Houston, Texas-77004</font></div></div></div></div></div>
</div></div>