Skip to content

Commit a0e3418

Browse files
committed
[flang][OpenMP] Add fortran test with basic target region
This patch adds a test that uses a target region to set a scalar value. It also adds rules in lit.cfg to handle fortran testing. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D159216
1 parent 03f338e commit a0e3418

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

openmp/libomptarget/test/lit.cfg

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def evaluate_bool_env(env):
5858
config.name = 'libomptarget :: ' + config.libomptarget_current_target
5959

6060
# suffixes: A list of file extensions to treat as test files.
61-
config.suffixes = ['.c', '.cpp', '.cc']
61+
config.suffixes = ['.c', '.cpp', '.cc', '.f90']
62+
63+
# excludes: A list of directories to exclude from the testuites.
64+
config.excludes = ['Inputs']
6265

6366
# test_source_root: The root path where tests are located.
6467
config.test_source_root = os.path.dirname(__file__)
@@ -162,6 +165,8 @@ for libomptarget_target in config.libomptarget_all_targets:
162165
"%libomptarget-compilexx-run-and-check-" + libomptarget_target))
163166
config.substitutions.append(("%libomptarget-compile-run-and-check-generic",
164167
"%libomptarget-compile-run-and-check-" + libomptarget_target))
168+
config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-generic",
169+
"%libomptarget-compile-fortran-run-and-check-" + libomptarget_target))
165170
config.substitutions.append(("%libomptarget-compilexx-and-run-generic",
166171
"%libomptarget-compilexx-and-run-" + libomptarget_target))
167172
config.substitutions.append(("%libomptarget-compile-and-run-generic",
@@ -170,6 +175,8 @@ for libomptarget_target in config.libomptarget_all_targets:
170175
"%libomptarget-compilexx-" + libomptarget_target))
171176
config.substitutions.append(("%libomptarget-compile-generic",
172177
"%libomptarget-compile-" + libomptarget_target))
178+
config.substitutions.append(("%libomptarget-compile-fortran-generic",
179+
"%libomptarget-compile-fortran-" + libomptarget_target))
173180
config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-generic",
174181
"%libomptarget-compileoptxx-run-and-check-" + libomptarget_target))
175182
config.substitutions.append(("%libomptarget-compileopt-run-and-check-generic",
@@ -204,6 +211,10 @@ for libomptarget_target in config.libomptarget_all_targets:
204211
libomptarget_target, \
205212
"%libomptarget-compile-and-run-" + libomptarget_target + \
206213
" | " + config.libomptarget_filecheck + " %s"))
214+
config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-" + \
215+
libomptarget_target, \
216+
"%libomptarget-compile-fortran-and-run-" + libomptarget_target + \
217+
" | " + config.libomptarget_filecheck + " %s"))
207218
config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
208219
libomptarget_target, \
209220
"%libomptarget-compilexx-" + libomptarget_target + " && " + \
@@ -212,6 +223,10 @@ for libomptarget_target in config.libomptarget_all_targets:
212223
libomptarget_target, \
213224
"%libomptarget-compile-" + libomptarget_target + " && " + \
214225
"%libomptarget-run-" + libomptarget_target))
226+
config.substitutions.append(("%libomptarget-compile-fortran-and-run-" + \
227+
libomptarget_target, \
228+
"%libomptarget-compile-fortran-" + libomptarget_target + " && " + \
229+
"%libomptarget-run-" + libomptarget_target))
215230
config.substitutions.append(("%libomptarget-compilexx-" + \
216231
libomptarget_target, \
217232
"%clangxx-" + libomptarget_target + " %s -o %t" + \
@@ -220,6 +235,9 @@ for libomptarget_target in config.libomptarget_all_targets:
220235
libomptarget_target, \
221236
"%clang-" + libomptarget_target + " %s -o %t" +
222237
(" -lcgpu" if config.libomptarget_has_libc else "")))
238+
config.substitutions.append(("%libomptarget-compile-fortran-" + \
239+
libomptarget_target, \
240+
"%flang-" + libomptarget_target + " %s -o %t"))
223241
config.substitutions.append(("%libomptarget-compileoptxx-run-and-check-" + \
224242
libomptarget_target, \
225243
"%libomptarget-compileoptxx-and-run-" + libomptarget_target + \
@@ -256,18 +274,27 @@ for libomptarget_target in config.libomptarget_all_targets:
256274
config.substitutions.append(("%clang-" + libomptarget_target, \
257275
"%clang %openmp_flags %cuda_flags %flags -fopenmp-targets=" +\
258276
remove_suffix_if_present(libomptarget_target)))
277+
config.substitutions.append(("%flang-" + libomptarget_target, \
278+
"%flang %openmp_flags %flags -fopenmp-targets=" +\
279+
remove_suffix_if_present(libomptarget_target)))
259280
config.substitutions.append(("%fcheck-" + libomptarget_target, \
260281
config.libomptarget_filecheck + " %s"))
261282
else:
262283
config.substitutions.append(("%libomptarget-compile-run-and-check-" + \
263284
libomptarget_target, \
264285
"echo ignored-command"))
286+
config.substitutions.append(("%libomptarget-compile-fortran-run-and-check-" + \
287+
libomptarget_target, \
288+
"echo ignored-command"))
265289
config.substitutions.append(("%libomptarget-compilexx-run-and-check-" + \
266290
libomptarget_target, \
267291
"echo ignored-command"))
268292
config.substitutions.append(("%libomptarget-compile-and-run-" + \
269293
libomptarget_target, \
270294
"echo ignored-command"))
295+
config.substitutions.append(("%libomptarget-compile-fortran-and-run-" + \
296+
libomptarget_target, \
297+
"echo ignored-command"))
271298
config.substitutions.append(("%libomptarget-compilexx-and-run-" + \
272299
libomptarget_target, \
273300
"echo ignored-command"))
@@ -277,6 +304,9 @@ for libomptarget_target in config.libomptarget_all_targets:
277304
config.substitutions.append(("%libomptarget-compile-" + \
278305
libomptarget_target, \
279306
"echo ignored-command"))
307+
config.substitutions.append(("%libomptarget-compile-fortran-" + \
308+
libomptarget_target, \
309+
"echo ignored-command"))
280310
config.substitutions.append(("%libomptarget-compileopt-run-and-check-" + \
281311
libomptarget_target, \
282312
"echo ignored-command"))
@@ -307,6 +337,8 @@ for libomptarget_target in config.libomptarget_all_targets:
307337
"echo ignored-command"))
308338
config.substitutions.append(("%fcheck-" + libomptarget_target, \
309339
"echo ignored-command"))
340+
config.substitutions.append(("%flang-" + libomptarget_target, \
341+
"echo ignored-command"))
310342

311343
config.substitutions.append(("%clangxx", config.test_cxx_compiler))
312344
config.substitutions.append(("%clang", config.test_c_compiler))

openmp/libomptarget/test/offloading/fortran/basic_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// REQUIRES: flang, amdgcn-amd-amdhsa
33

44
// RUN: %flang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
5-
// RUN: %S/basic_array.f90 -o basic_array.o
5+
// RUN: %S/../../Inputs/basic_array.f90 -o basic_array.o
66
// RUN: %libomptarget-compile-generic basic_array.o
77
// RUN: %t | %fcheck-generic
88

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! Basic offloading test with a target region
2+
! REQUIRES: flang, amdgcn-amd-amdhsa
3+
! UNSUPPORTED: nvptx64-nvidia-cuda
4+
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
5+
! UNSUPPORTED: aarch64-unknown-linux-gnu
6+
! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
7+
! UNSUPPORTED: x86_64-pc-linux-gnu
8+
! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
9+
10+
! RUN: %libomptarget-compile-fortran-run-and-check-generic
11+
program main
12+
integer :: x;
13+
x = 0
14+
!$omp target map(from:x)
15+
x = 5
16+
!$omp end target
17+
print *, "x = ", x
18+
end program main
19+
20+
! CHECK: x = 5
21+

0 commit comments

Comments
 (0)