Quantcast
Channel: Intel® Many Integrated Core Architecture
Viewing all articles
Browse latest Browse all 1347

Offload error: signal 11 (SIGSEGV) for simple code

$
0
0

This is my first post on the forum, so please be gentle. I've been experimenting with a Phi card for some parallel CFD solvers. Preliminary results are fine - however, I've encountered some interesting problems when using #pragma ivdep for some simple vector calculation. Here is a stripped down version of the code that produces the error:

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>     

#include <offload.h>

#include <omp.h>

int main() {

    double *p0, *p1;

    double *u0, *u1;

    size_t alignment = 64;

    int error;

    int NC = 1000;

    int i;

    // Allocate memory

    error = posix_memalign((void**)&p0, alignment, NC*sizeof(double));

    error = posix_memalign((void**)&p1, alignment, NC*sizeof(double));

    error = posix_memalign((void**)&u0, alignment, NC*sizeof(double));

    error = posix_memalign((void**)&u1, alignment, NC*sizeof(double));

    

    // Initialize data

    for (i = 0; i < NC; i++) {

        p0[i] = 1.0;  u0[i] = p0[i];

        p1[i] = 2.0;  u1[i] = p0[i]*p1[i];

    }

    // Offload to Phi

    #pragma offload target(mic:0) inout(p0,p1,u0,u1:length(NC))

    {

        omp_set_num_threads(10);  

        #pragma omp parallel shared(u0, u1, p0, p1)

        {

            #pragma omp for

            #pragma vector aligned

            #pragma ivdep

            for (i = 0; i < NC; i++) {

                p0[i] = u0[i];

                p1[i] = u1[i]/u0[i];

            }

        } // End of OMP parallel section

    } // End of Phi offload

    // Free memory

    free(p0); free(p1);

    free(u0); free(u1);

    return 0;

}

The build instruction (taken from the makefile) is: icc -opt-report-phase=offload -offload-attribute-target=mic -openmp -O3 crash.cpp -o test.run  



When this is run, I see a message reporting an offload error - process terminated by signal 11 (SIGSEGV). If I remove "#pragma ivdep", the code runs without any trouble. I've written the same code using intrinsic functions with openmp, which also runs without any trouble - hence, I know this section of code can be vectorized without any drama, but I'm having trouble doing this without resorting to intrinsic functions. I can provide the output of the offload report if anyone is interested. I suspect the Phi is trying to access data on the host, which is causing the seg fault. If anyone has any ideas on this, it would be fantastic. If I'm posting in the wrong spot, please let me know.

Cheers!

 

 

 

 


Viewing all articles
Browse latest Browse all 1347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>