0

I have problems when offloading some datastructures to my MIC.

I am offloading into MIC with the following directives:

    #pragma offload target(mic:mic_no)\
    inout(is_selected : length(query_sequences_count)ALLOC)\
    in(a:length(a_size) ALLOC)\
    in(a_disp:length(offload_db_count)ALLOC)

However if I try to execute inside the offloaded region:

//loads next 64 characters of a into datadb
__m512i datadb __attribute__ ((aligned(64)));
datadb = _mm512_load_epi32(a+iter_db+a_disp[j]);

This causes the following error:

Offload error:process on the device 0 was terminated by signal 11(SIGSEGV)

But if I instead copy the content of a into another array like this:

char db[64];
for(window_db_iter = 0; window_db_iter < 64; window_db_iter++)
    db[window_db_iter] = *(a+iter_db+a_disp[j]+window_db_iter);

//Now this works fine
datadb = _mm512_load_epi32(db);

I have checked that a offloads with the correct length, a_size is the size of a and that a_disp is correct as well. Also a+iter_db+a_disp[j] remains always inside the bounds of memory. My guess is that it has to do with the process of copying the memory onto the MIC. Any ideas?

Thanks!

Felipe Sulser
  • 1,185
  • 8
  • 19

1 Answers1

0

After some time, I have found the answer to my question.

  • First the data structure needs to be aligned. If not, it is going to return an error. The Offload error does not mean the error was caused during the process of copying memory from host CPU to coprocessor, it can be caused anywhere in the code.

  • Second, if you have unaligned memory and cannot/dont want to align it you can use the align modifier during the offload like this:

    #pragma offload target(mic:mic_no)\
    inout(is_selected : length(query_sequences_count)ALLOC)\
    in(a[0:a_size]: aligned(64) ALLOC)\
    in(a_disp:length(offload_db_count)ALLOC)
    

Now the copied memory will be copied aligned.

Felipe Sulser
  • 1,185
  • 8
  • 19