Skip to content

Incorrect outlining for C++ OpenMP code #144

@ouankou

Description

@ouankou

Given the input:

#pragma omp target parallel for 
for (int i = 0; i < n; ++i)
    y[i] += a * x[i];

If it's in a C file, the kernel is OK. Variable a is rewritten as *ap__ and used correctly.

__global__ void OUT__1__7822__axpy_omp__48__kernel__(long *np__,double *ap__,double *_dev_x,double *_dev_y) {
...
for (i = _dev_lower; ((long )i) <= _dev_upper; i += 1) {
        _dev_y[i] +=  *ap__ * _dev_x[I];    // *ap__ is used. Correct. 
      }
}

However, if the same OpenMP code is in a C++ file. The generated kernel would be:

__global__ void OUT__1__7822__axpy_omp__48__kernel__(long *np__,double *ap__,double *_dev_x,double *_dev_y) {
...
for (i = _dev_lower; ((long )i) <= _dev_upper; i += 1) {
        _dev_y[i] +=  ap__ * _dev_x[i];    // ap__ is used. Incorrect.
      }
}

Please notice that ap__ is used as a pointer without dereferencing.

I've checked the lowering and outlining modules. So far, no C++-specific handler has been found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions