Quantcast
Channel: Intel® Software - OpenCL*
Viewing all articles
Browse latest Browse all 1182

OpenCL source file does not compile with Intel OpenCL SDK

$
0
0

Hi to everyone,

I am facing (another) strange problem with one of my codes. I have been working since some time on a MC code for particle transport using OpenCL. In the last weeks we are facing a strange problem with one of the source files, and specifically, with a function inside it.

The problem is that the compilation process hangs when an Intel SDK is used. We have tested on several systems and always when the Intel platform is targeted the compilation takes forever and does not finish (I leave the PC during the weekend and the compilation did not finished). More specifically, this happens when the Intel CPU is targeted (strangely with the GPU compiles and then the program executes without issues)

Doing some testing we realized that the problem is with the following function inside the *.cl source file:

void howfar(
            // Particle information
            particle_t *p,
            
            // Geometry data.
            __global int3 *ngrid,
            __global float *xbounds,
            __global float *ybounds,
            __global float *zbounds,
            
            // Output information
            int *idisc,
            int *irnew,
            float *ustep) {
    
    float dist = 0.0f;  // distance to boundary along particle trajectory
    
    if (p->ir == 0) {   // the particle is outside the geometry
        *idisc = 1; // terminate history
        return;
    }
    else {  // in the geometry, do transport checks
        int ijmax = ngrid[0].x * ngrid[0].y;
        int imax = ngrid[0].x;
        
        /* First we need to decode the region number of the particle in terms
         of the region indices in each direction. */
        int irx = (p->ir - 1) % imax;
        int irz = (p->ir - 1 - irx) / ijmax;
        int iry = ((p->ir - 1 - irx) - irz * ijmax) / imax;
        
        /* Check in z-direction. */
        if (p->u.z > 0.0f) { // going towards outer plane
            dist = (zbounds[irz + 1] -    p->r.z) / p->u.z;
            if (dist < *ustep) {
                *ustep = dist;
                if (irz != (ngrid[0].z - 1)) {
                    *irnew = p->ir + ijmax;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
        else if (p->u.z < 0.0f) { // going towards inner plane
            dist = -(p->r.z - zbounds[irz]) / p->u.z;
            if (dist < *ustep) {
                *ustep = dist;
                if (irz != 0) {
                    *irnew = p->ir - ijmax;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
        /* Check in x-direction. */
        if (p->u.x > 0.0f) { // going towards positive plane
            dist = (xbounds[irx + 1] - p->r.x) / p->u.x;
            if (dist < *ustep) {
                *ustep = dist;
                if (irx != (ngrid[0].x - 1)) {
                    *irnew = p->ir + 1;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
        else if (p->u.x < 0.0f) { // going towards negative plane
            dist = -(p->r.x - xbounds[irx]) / p->u.x;
            if (dist < *ustep) {
                *ustep = dist;
                if (irx != 0) {
                    *irnew = p->ir - 1;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
        /* Check in y-direction. */
        if (p->u.y > 0.0f) { // going towards positive plane
            dist = (ybounds[iry + 1] - p->r.y) / p->u.y;
            if (dist < *ustep) {
                *ustep = dist;
                if (iry != (ngrid[0].y - 1)) {
                    *irnew = p->ir + imax;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
        else if (p->u.y < 0.0f) { // going towards negative plane
            dist = -(p->r.y - ybounds[iry]) / p->u.y;
            if (dist < *ustep) {
                *ustep = dist;
                if (iry != 0) {
                    *irnew = p->ir - imax;
                }
                else {
                    *irnew = 0; // leaving geometry
                }
            }
        }
        
    }
    
    return;
    
}

For testing purposes, if I delete everything inside (empty function) and/or remove the call to the function in the kernel the compilation process finishes without problems. Aditionally, if I target NVIDIA or AMD platforms the code compiles and executes without issues, and even in macOS using the Apple OpenCL framework (with Intel CPU and GPU) the code also compiles and executes without problems. I attached a sample code that can be executed and/or compiled using CodeBuilder.

Unfortunally I have no clue of what is going on. The function is not the most complex that I have seen and really I am not able to see the problem, and I have no output during the compilation process that could give me a clue of what is happening. Thanks for your help!


Viewing all articles
Browse latest Browse all 1182

Trending Articles



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