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

Global declare target pointer cannot be accessed in target region

Open jyu2-git opened this issue 6 years ago • 2 comments

Bugzilla Link 46824
Resolution FIXED
Resolved on Jul 30, 2020 06:43
Version trunk
OS All
CC @alexey-bataev
Fixed by commit(s) 142d0d3ed8e07aca2476bc4ecc1a12d15577a84a

jyu2-git avatar Jul 23 '20 16:07 jyu2-git

Fixed in 142d0d3ed8e07aca2476bc4ecc1a12d15577a84a

alexey-bataev avatar Jul 30 '20 13:07 alexey-bataev

This is seamier with 46012 but using ExecutableDirective.

#include <stdio.h> #include <stdlib.h>

#pragma omp declare target int * arr; #pragma omp end declare target

#pragma omp declare target void foo(int i) { arr[i] = i; } #pragma omp end declare target

int main(void) { // Allocate array and set to zero int len = 6; arr = (int *) calloc( len, sizeof(int) );

// Map and fill with values on device #pragma omp target teams distribute parallel for
map(tofrom: arr[:len]) for( int i = 0; i < len; i++) { // Calling foo appears to have no effect foo(i);

// If we uncomment this to inline the contents of foo, it works correctly.
//arr[i] = i;

}

// Print expected and actual arrays on host printf("Expected Result: 0 1 2 3 4 5\n"); printf("Actual Result: "); for( int i = 0; i < len; i++) printf("%d ", arr[i]); printf("\n");

// Return non-zero error code if we failed if( arr[5] != 5 ) { printf("Error!\n"); return 1; }

return 0; }

jyu2-git avatar Jul 23 '20 16:07 jyu2-git