<div dir="ltr">Hi Andrey,<div><br></div><div>Thank you very much for your time and nice explanation. You are right I couldn't access the data location. </div><div>I am thinking to add a runtime call with shared data reference, let us see what I get. And please share better idea if you have any.</div><div><br></div><div>Best Regards,</div><div>- Raju</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 11:02 AM, Churbanov, Andrey <span dir="ltr"><<a href="mailto:Andrey.Churbanov@intel.com" target="_blank">Andrey.Churbanov@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="RU" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hello,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">If you print information from __kmp_task_alloc() function, you cannot find your data in the structures.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The reason is that this routine only allocates space requested by the compiler and initializes its own runtime-related
info, and if you examine the space allocated for shareds you can only find uninitialized memory there.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">The addresses of shared variables are put into allocated memory by the compiler later, AFTER the __kmp_task_alloc() call.
E.g. the array of shareds should already be initialized in the __kmp_omp_task() call. But I doubt you can rely on particular location of any shared variable in the array of shareds, it is compiler’s decision where to place your particular variable’s address,
and it may or may not be the first in the array of shareds. E.g. compiler can insert its own auxiliary data before user’s data.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Andrey<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><a name="151a697fedbb6062______replyseparator"></a><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Openmp-dev [mailto:<a href="mailto:openmp-dev-bounces@lists.llvm.org" target="_blank">openmp-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Rezaul Karim Raju via Openmp-dev<br>
<b>Sent:</b> Tuesday, December 15, 2015 8:47 AM<br>
<b>To:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a>; <a href="mailto:openmp-commits@lists.llvm.org" target="_blank">openmp-commits@lists.llvm.org</a><br>
<b>Subject:</b> [Openmp-dev] Intel OpenMP Runtime & LLVM [kmp_tasking.c]: Problem to access SHARED VARIABLE DATA LOCATION<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Dear concern, <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Please consider the source code(openmp c code) snippet as below: <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">--- code snippet ---<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">int a1, b1, c1, N;<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Initially address of a1:= 0x7fff9bd58304 <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">omp_set_num_threads(2);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #pragma omp parallel<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #pragma omp single<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> // task one: a1=b1+c1;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #pragma omp task shared(a1) firstprivate(b1,c1)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> a1 = a1 + b1 + c1;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">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.
<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">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
<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I am trying to access the "shared variable data location for a task" which is as below: <u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">kmp_task_t *<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">__kmp_task_alloc(...){<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">kmp_task_t *task;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">kmp_taskdata_t *taskdata;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">// Calculate shared structure offset including padding after kmp_task_t struct<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> // to align pointers in shared struct<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> shareds_offset = sizeof( kmp_taskdata_t ) + sizeof_kmp_task_t;<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> shareds_offset = __kmp_round_up_to_val( shareds_offset, sizeof( void * ));<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">// Avoid double allocation here by combining shareds with taskdata<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #if USE_FAST_MEMORY<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> taskdata = (kmp_taskdata_t *) __kmp_fast_allocate( thread, shareds_offset + sizeof_shareds );<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #else /* ! USE_FAST_MEMORY */<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> taskdata = (kmp_taskdata_t *) __kmp_thread_malloc( thread, shareds_offset + sizeof_shareds );<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> #endif /* USE_FAST_MEMORY */<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal">task = KMP_TASKDATA_TO_TASK(taskdata);<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">if (sizeof_shareds > 0) {<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> // Avoid double allocation here by combining shareds with taskdata<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> task->shareds = & ((char *) taskdata)[ shareds_offset ];<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">printf("task->shareds address original:= %p address of pointer it points to := %p\n", & ((char *) taskdata)[ shareds_offset ], *task->shareds);<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> }<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal">}<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">here, <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">typedef struct kmp_task { /* GEH: Shouldn't this be aligned somehow? */<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> void * shareds; /**< pointer to block of pointers to shared vars */<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">}<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">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) <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">IT PRINTS DIFFERENT ADDRESS: <0x1fe0ef0><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">NEED TO GET THE ADDRESS OF TASK'S SHARED VARIABLE ADDRESS FROM RUNTIME.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">appreciate your comment and help. Thanking you.<u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#cccccc">------------------------</span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#999999">RaJu, Rezaul Karim<br>
Graduate Student (PhD) | Computer Science | University of Houston</span><u></u><u></u></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#999999">Research in High Performance Computing Tools </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;color:#999999">Houston, Texas-77004</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div></div>
<p><br>--------------------------------------------------------------------<br>Joint Stock Company Intel A/O<br>Registered legal address: Krylatsky Hills Business Park, <br>17 Krylatskaya Str., Bldg 4, Moscow 121614, <br>Russian Federation</p><p>This e-mail and any attachments may contain confidential material for<br>the sole use of the intended recipient(s). Any review or distribution<br>by others is strictly prohibited. If you are not the intended<br>recipient, please contact the sender and delete all copies.</p>
</div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><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>