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

Xeon Phi Segmentation Fault Simple Offload

$
0
0

I have this simple matrix multiply for offload on Phi, but I get  offload error (SIGSEGV) when I run the program below:

#include <stdlib.h>

#include <math.h>

void main()

{

    double *a, *b, *c; 

    int i,j,k, ok, n=100;

    // allocated memory on the heap aligned to 64 byte boundary 

    ok = posix_memalign((void**)&a, 64, n*n*sizeof(double)); 

    ok |= posix_memalign((void**)&b, 64, n*n*sizeof(double)); 

    ok |= posix_memalign((void**)&c, 64, n*n*sizeof(double));



    // initialize matrices 

    for(i=0; i<n; i++)

    {

        a[i] = (int) rand();

        b[i] = (int) rand();

        c[i] = 0.0;

    }

    

    //offload code 

    #pragma offload target(mic) in(a,b:length(n*n)) inout(c:length(n*n)) 

    

    //parallelize via OpenMP on MIC 

    #pragma omp parallel for 

    for( i = 0; i < n; i++ ) 

        for( k = 0; k < n; k++ ) 

            #pragma vector aligned 

            #pragma ivdep 

            for( j = 0; j < n; j++ ) 

                //c[i][j] = c[i][j] + a[i][k]*b[k][j]; 

                    c[i*n+j] = c[i*n+j] + a[i*n+k]*b[k*n+j];

}

What am I doing wrong?

I read a previous post that there might be a known bug in the release?

 

 


Viewing all articles
Browse latest Browse all 1347

Trending Articles



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