mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:46:05 +00:00

OpenACC restricts the contents of a 'for' loop affected by a 'loop' construct without a 'seq'. The loop variable must be integer, pointer, or random-access-iterator, it must monotonically increase/decrease, and the trip count must be computable at runtime before the function. This patch tries to implement some of these limitations to the best of our ability, though it causes us to be perhaps overly restrictive at the moment. I expect we'll revisit some of these rules/add additional supported forms of loop-variable and 'monotonically increasing' here, but the currently enforced rules are heavily inspired by the OMP implementation here.
43 lines
1.3 KiB
C
43 lines
1.3 KiB
C
// RUN: %clang_cc1 %s -fopenacc -verify
|
|
|
|
struct NotConvertible{} NC;
|
|
short getS();
|
|
int getI();
|
|
|
|
void uses() {
|
|
int arr[5];
|
|
|
|
#pragma acc parallel wait
|
|
while(1);
|
|
|
|
#pragma acc serial wait()
|
|
while(1);
|
|
|
|
#pragma acc kernels wait(getS(), getI())
|
|
while(1);
|
|
|
|
#pragma acc parallel wait(devnum:getS(): getI())
|
|
while(1);
|
|
|
|
#pragma acc parallel wait(devnum:getS(): queues: getI()) wait(devnum:getI(): queues: getS(), getI(), 5)
|
|
while(1);
|
|
|
|
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
|
|
#pragma acc parallel wait(devnum:NC : 5)
|
|
while(1);
|
|
|
|
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
|
|
#pragma acc parallel wait(devnum:5 : NC)
|
|
while(1);
|
|
|
|
// expected-error@+3{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
|
|
// expected-error@+2{{OpenACC clause 'wait' requires expression of integer type ('int[5]' invalid)}}
|
|
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
|
|
#pragma acc parallel wait(devnum:arr : queues: arr, NC, 5)
|
|
while(1);
|
|
|
|
// expected-error@+1{{OpenACC 'wait' clause is not valid on 'loop' directive}}
|
|
#pragma acc loop wait
|
|
for(int i = 5; i < 10;++i);
|
|
}
|