llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

firstprivate of declare target variable

Open kkwli opened this issue 5 years ago • 0 comments

Bugzilla Link 49098
Resolution FIXED
Resolved on Apr 28, 2021 05:47
Version unspecified
OS All
CC @alexey-bataev,@jdoerfert
Fixed by commit(s) c835630c25a4f9925517949579f66a43b113fbc9

Extended Description

The explicit firstprivate clause should be respected on the target construct. In this case, clang seems to reference the mapped 'ga' instead of the firstprivate 'ga'.

#include <stdio.h>

#pragma omp declare target int ga = 5; #pragma omp end declare target

int main() { ga = 100;

#pragma omp target firstprivate(ga) { ga += 10; printf("on device, ga = %d\n", ga); } printf("on host, ga = %d\n", ga); return 0; }

Current output: on device, ga = 15 on host, ga = 100

Expected output: on device, ga = 110 on host, ga = 100

kkwli avatar Feb 08 '21 23:02 kkwli