[Openmp-commits] [Openmp-dev] Intel OpenMP Runtime & LLVM [kmp_tasking.c]: Problem to access SHARED VARIABLE DATA LOCATION

Rezaul Karim Raju via Openmp-commits openmp-commits at lists.llvm.org
Fri Dec 18 10:02:36 PST 2015


Hi Andrey,

Thank you very much for your time and nice explanation. You are right I
couldn't access the data location.
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.

Best Regards,
- Raju

On Tue, Dec 15, 2015 at 11:02 AM, Churbanov, Andrey <
Andrey.Churbanov at intel.com> wrote:

> Hello,
>
>
>
> If you print information from __kmp_task_alloc() function, you cannot find
> your data in the structures.
>
> 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.
>
>
>
> 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.
>
>
>
> Regards,
>
> Andrey
>
>
>
> *From:* Openmp-dev [mailto:openmp-dev-bounces at lists.llvm.org] *On Behalf
> Of *Rezaul Karim Raju via Openmp-dev
> *Sent:* Tuesday, December 15, 2015 8:47 AM
> *To:* openmp-dev at lists.llvm.org; openmp-commits at lists.llvm.org
> *Subject:* [Openmp-dev] Intel OpenMP Runtime & LLVM [kmp_tasking.c]:
> Problem to access SHARED VARIABLE DATA LOCATION
>
>
>
> 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 <src>
> 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.
>
> ------------------------
>
> RaJu, Rezaul Karim
> Graduate Student (PhD) | Computer Science | University of Houston
>
> Research in High Performance Computing Tools
>
> Houston, Texas-77004
>
>
> --------------------------------------------------------------------
> Joint Stock Company Intel A/O
> Registered legal address: Krylatsky Hills Business Park,
> 17 Krylatskaya Str., Bldg 4, Moscow 121614,
> Russian Federation
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>



-- 
------------------------
RaJu, Rezaul Karim
Graduate Student (PhD) | Computer Science | University of Houston
Research in High Performance Computing Tools
Houston, Texas-77004
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20151218/37c91b24/attachment-0001.html>


More information about the Openmp-commits mailing list