1d84dedc7SAndreyChurbanov // The test supposes no offload, pure host execution. 2d84dedc7SAndreyChurbanov // It checks that the bug in implementation of distribute construct is fixed. 3d84dedc7SAndreyChurbanov 4d84dedc7SAndreyChurbanov // RUN: %libomp-compile-and-run 5*fe7f620eSJoachim Jenke 6*fe7f620eSJoachim Jenke // gcc/icc target offloading is incompatible with libomp 7*fe7f620eSJoachim Jenke // UNSUPPORTED: icc, gcc 8d84dedc7SAndreyChurbanov 9d84dedc7SAndreyChurbanov #include <stdio.h> 10d84dedc7SAndreyChurbanov #include <omp.h> 11d84dedc7SAndreyChurbanov main()12d84dedc7SAndreyChurbanovint main() 13d84dedc7SAndreyChurbanov { 14d84dedc7SAndreyChurbanov const int size = 4; 15d84dedc7SAndreyChurbanov int wrong_counts = 0; 16d84dedc7SAndreyChurbanov omp_set_num_threads(2); 17d84dedc7SAndreyChurbanov #pragma omp parallel reduction(+:wrong_counts) 18d84dedc7SAndreyChurbanov { 19d84dedc7SAndreyChurbanov int i; 20d84dedc7SAndreyChurbanov int A[size]; 21d84dedc7SAndreyChurbanov int th = omp_get_thread_num(); 22d84dedc7SAndreyChurbanov for(i = 0; i < size; i++) 23d84dedc7SAndreyChurbanov A[i] = 0; 24d84dedc7SAndreyChurbanov 25d84dedc7SAndreyChurbanov #pragma omp target teams distribute map(tofrom: A[:size]) private(i) 26d84dedc7SAndreyChurbanov for(i = 0; i < size; i++) 27d84dedc7SAndreyChurbanov { 28d84dedc7SAndreyChurbanov A[i] = i; 29d84dedc7SAndreyChurbanov printf("th %d, team %d, i %d\n", th, omp_get_team_num(), i); 30d84dedc7SAndreyChurbanov } 31d84dedc7SAndreyChurbanov #pragma omp critical 32d84dedc7SAndreyChurbanov { 33d84dedc7SAndreyChurbanov printf("tid = %d\n", th); 34d84dedc7SAndreyChurbanov for(i = 0; i < size; i++) 35d84dedc7SAndreyChurbanov { 36d84dedc7SAndreyChurbanov if (A[i] != i) wrong_counts++; 37d84dedc7SAndreyChurbanov printf(" %d", A[i]); 38d84dedc7SAndreyChurbanov } 39d84dedc7SAndreyChurbanov printf("\n"); 40d84dedc7SAndreyChurbanov } 41d84dedc7SAndreyChurbanov } 42d84dedc7SAndreyChurbanov if (wrong_counts) { 43d84dedc7SAndreyChurbanov printf("failed\n"); 44d84dedc7SAndreyChurbanov } else { 45d84dedc7SAndreyChurbanov printf("passed\n"); 46d84dedc7SAndreyChurbanov } 47d84dedc7SAndreyChurbanov return wrong_counts; 48d84dedc7SAndreyChurbanov } 49