2 // RUN: %libomptarget-compile-generic -DREQ=1 && %libomptarget-run-generic 2>&1 | %fcheck-generic -check-prefix=GOOD
3 // RUN: %libomptarget-compile-generic -DREQ=2 && not %libomptarget-run-generic 2>&1 | %fcheck-generic -check-prefix=BAD
7 Test for the 'requires' clause check.
8 When a target region is used, the requires flags are set in the
9 runtime for the entire compilation unit. If the flags are set again,
10 (for whatever reason) the set must be consistent with previously
16 // ---------------------------------------------------------------------------
17 // Various definitions copied from OpenMP RTL
25 } __tgt_offload_entry
;
28 OMP_REGISTER_REQUIRES
= 0x10,
34 __tgt_offload_entry
*EntriesBegin
;
35 __tgt_offload_entry
*EntriesEnd
;
39 int32_t NumDeviceImages
;
40 __tgt_device_image
*DeviceImages
;
41 __tgt_offload_entry
*HostEntriesBegin
;
42 __tgt_offload_entry
*HostEntriesEnd
;
45 void __tgt_register_lib(__tgt_bin_desc
*Desc
);
46 void __tgt_unregister_lib(__tgt_bin_desc
*Desc
);
48 // End of definitions copied from OpenMP RTL.
49 // ---------------------------------------------------------------------------
51 void run_reg_requires() {
52 // Before the target region is registered, the requires registers the status
53 // of the requires clauses. Since there are no requires clauses in this file
54 // the flags state can only be OMP_REQ_NONE i.e. 1.
56 // This is the 2nd time this function is called so it should print SUCCESS if
57 // REQ is compatible with `1` and otherwise cause an error.
58 __tgt_offload_entry entries
[] = {{NULL
, "", 0, OMP_REGISTER_REQUIRES
, 1},
59 {NULL
, "", 0, OMP_REGISTER_REQUIRES
, REQ
}};
60 __tgt_device_image image
= {NULL
, NULL
, &entries
[0], &entries
[1] + 1};
61 __tgt_bin_desc bin
= {1, &image
, &entries
[0], &entries
[1] + 1};
63 __tgt_register_lib(&bin
);
67 __tgt_unregister_lib(&bin
);
71 // BAD: omptarget fatal error 2: '#pragma omp requires reverse_offload' not used consistently!
75 // ---------------------------------------------------------------------------
79 // This also runs reg requires for the first time.