sstsimulator / sst-macro

SST Macro Element Library
http://sst-simulator.org/
Other
34 stars 41 forks source link

Pragma deletion logic bug with omp pragmas. #577

Open calewis opened 3 years ago

calewis commented 3 years ago

Follow function:

void foo(){
#pragma sst memory 3
#pragma omp parallel for
for(auto i = 0; i < 10; ++i){}
}

Skeletonizes too:

void foo() {

#pragma omp parallel for
  {
    uint64_t flops = 0;
    uint64_t readBytes = 0;
    uint64_t writeBytes = 0;
    uint64_t intops = 0;
    { uint64_t tripCount0 = (((10) - (0))); }
    readBytes = 3;
    sstmac_compute_detailed(flops, intops, readBytes);
  }
}

which happens to work if you don't compile with -fopenmp because the omp pragma is ignored but the behavior still needs fixing. The issue can be seen here:

void
PragmaActivateGuard::deletePragmaText(SSTPragma *prg)
{
  //eliminate the pragma text
  if (prg->depth == 0){
    SourceRange rng(prg->pragmaDirectiveLoc, prg->endPragmaLoc);
    ::replace(rng, "");
  }
}

Even though the second pragma might ask to be deleted, if it is isn't the first pragma it won't be deleted. The conflict with OpenMP pragmas can probably be worked around by avoiding activating the openmp compiler flag, but we should probably still fix this because their could be other issues with not properly deleting pragma text.