Community
cancel
Showing results for 
Search instead for 
Did you mean: 
rachael_g_
Beginner
132 Views

kmp_csupport.c: No such file or directory.

I am trying to write a code using OpenMP to be run in Xeon Phi. Following are some snippets of code:

#include<stdio.h>
#include<omp.h>
#include<sys/time.h
#include<stdlib.h>
#include<math.h>


#pragma offload_attribute(push,target(mic))

#define EVENTS 10
#define POINTS 4230
#define DIMS 3
#define TRIPLET 2000
#define FITPOINT 4
#define MaxPoints 25
#pragma offload_attribute(pop)

typedef struct PointList
{
        unsigned int index;
        float valuex;
        float valuey;
        float valuez;
}__declspec(target(mic)) PointList;

__declspec(target(mic)) struct PointList *ThirdLastLayerPoints,*SecondLastLayerPoints,*LastLayerPoints;

void func1()
{
        int  a, b,c,n;
        int size_pt = EVENTS * MaxPoints * sizeof(PointList);
        printf("%d\n",size_pt);
        #pragma offload target(mic:0) in(LastLayerPoints:length(size_pt)) in(SecondLastLayerPoints:length(size_pt)) in(ThirdLastLayerPoints:length(size_pt)) inout(Result)
        {
                int ctr;
                #pragma omp parallel for
                for(ctr=0 ; ctr<EVENTS ; ctr++)
                {  // more code }

}


int main(int argc, char **argv)
{

        ThirdLastLayerPoints=(PointList *)malloc(EVENTS*MaxPoints*sizeof(PointList));
        SecondLastLayerPoints=(PointList *)malloc(EVENTS*MaxPoints*sizeof(PointList));
        LastLayerPoints=(PointList *)malloc(EVENTS*MaxPoints*sizeof(PointList));

       //more code

       func1();

       //code

}

when i try to execute the code I get this error :

offload error: allocation (base=0xa90050, size=64000) overlaps with existing allocation (base=0xa91000, size=64000)

On debugging:

89        #pragma offload target(mic:0) in(LastLayerPoints:length(size_pt)) in(SecondLastLayerPoints:length(size_pt)) in(ThirdLastLayerPoints:length(size_pt)) inout(Result)
(gdb)
__kmpc_global_thread_num (loc=0x62c4c0 <.2.20_2_kmpc_loc_struct_pack.12>) at ../../src/kmp_csupport.c:123
123    ../../src/kmp_csupport.c: No such file or directory.


I have libomp_oss. What am I doing wrong here? I am very new to this kind of programming.

 

 

 

0 Kudos
7 Replies
TimP
Black Belt
132 Views

This message was frequent prior to the introduction of 15.0 compilers, which apparently fixed some bugs.

Some topics to consider:

 Coprocessor stack size:

https://software.intel.com/en-us/node/522525

Setting a realistic number of threads et al:

https://software.intel.com/en-us/articles/best-known-methods-for-using-openmp-on-intel-many-integrat...

In my experience, the optimum number of threads for offload mode is less than for native execution. Still, you need more threads on coprocessor than you would use on host.

Note that the latest compilers are changing the environment variable name of KMP_PLACE_THREADS.  If you get the message urging you to use the new spelling, you must close your shell and start a new one if you choose to comply.

rachael_g_
Beginner
132 Views

Thank you TIm P. Changing the stack size helped in solving the offload error. However the code gives different and incorrect output every time it is executed. 

The same debugging message appears again.

Gregg_S_Intel
Employee
132 Views

Different and incorrect output is a symptom of a race condition in an OpenMP loop.  Something may be shared which should be private, etc.

Rajiv_D_Intel
Employee
132 Views

I believe the error is caused by using a byte-count in the #pragma offload instead of an element-count.

For instance, ThirdLastLayerPoints has been malloc'd with EVENTS*MaxPoints*sizeof(PointList) bytes, i.e. EVENTS*MaxPoints elements, each of size sizeof(PointList). Therefore, when transferring data using the pragma, the length expression should specify EVENTS*MaxPoints.

Make this change in all pragmas for all pointer variables. Use element-count, not byte-count.

Gregg_S_Intel
Employee
132 Views

I'll second Rajiv's diagnosis.  That explains also the race condition.

rachael_g_
Beginner
132 Views

I did make changes as mentioned. So, now the #pragma offload looks something like this

 #pragma offload target(mic:0) inout(result)  in(ThirdLastLayerPoints:length(EVENTS*MaxPoints)) in(SecondLastLayerPoints:length(EVENTS*MaxPoints)) in(LastLayerPoints:length(EVENTS*MaxPoints))

But I still get incorrect and different output. And also this message

(gdb)
__kmpc_global_thread_num (loc=0x62c4c0 <.2.20_2_kmpc_loc_struct_pack.12>) at ../../src/kmp_csupport.c:123
123    ../../src/kmp_csupport.c: No such file or directory.

 

 

 

Rajiv_D_Intel
Employee
132 Views

The gdb message is produced because the __kmpc functions are in the OpenMP lbrary and I don't think debug versions of them are shipped with the compiler.

The reason for incorrect results is hard to determine unless we have runnable code for your test program. Any number of things could be going wrong.

Reply