Debian Codegraph @

libgomp/testsuite/lib/libgomp.exp

raw
1 # Damn dejagnu for not having proper library search paths for load_lib.
2 # We have to explicitly load everything that gcc-dg.exp wants to load.
3
4 proc load_gcc_lib { filename } {
5 global srcdir loaded_libs
6
7 load_file $srcdir/../../gcc/testsuite/lib/$filename
8 set loaded_libs($filename) ""
9 }
10
11 load_lib dg.exp
12 load_lib standard.exp
13
14 # Required to use gcc-dg.exp - however, the latter should NOT be
15 # loaded until ${tool}_target_compile is defined since it uses that
16 # to determine default LTO options.
17
18 load_gcc_lib multiline.exp
19 load_gcc_lib prune.exp
20 load_gcc_lib target-libpath.exp
21 load_gcc_lib wrapper.exp
22 load_gcc_lib target-supports.exp
23 load_gcc_lib target-utils.exp
24 load_gcc_lib gcc-defs.exp
25 load_gcc_lib timeout.exp
26 load_gcc_lib file-format.exp
27 load_gcc_lib target-supports-dg.exp
28 load_gcc_lib scanasm.exp
29 load_gcc_lib scandump.exp
30 load_gcc_lib scanlang.exp
31 load_gcc_lib scanrtl.exp
32 load_gcc_lib scansarif.exp
33 load_gcc_lib scantree.exp
34 load_gcc_lib scanltrans.exp
35 load_gcc_lib scanoffload.exp
36 load_gcc_lib scanoffloadipa.exp
37 load_gcc_lib scanoffloadtree.exp
38 load_gcc_lib scanoffloadrtl.exp
39 load_gcc_lib scanipa.exp
40 load_gcc_lib scanwpaipa.exp
41 load_gcc_lib timeout-dg.exp
42 load_gcc_lib torture-options.exp
43 load_gcc_lib fortran-modules.exp
44 load_gcc_lib dg-test-cleanup.exp
45
46 # Try to load a test support file, built during libgomp configuration.
47 # Search in '..' vs. '.' to support parallel vs. sequential testing.
48 if [info exists ::env(GCC_RUNTEST_PARALLELIZE_DIR)] {
49 load_file ../libgomp-test-support.exp
50 } else {
51 load_file libgomp-test-support.exp
52 }
53
54 set dg-do-what-default run
55
56 set libgomp_compile_options ""
57
58 #
59 # libgomp_init
60 #
61
62 if [info exists TOOL_OPTIONS] {
63 set multilibs [get_multilibs $TOOL_OPTIONS]
64 } else {
65 set multilibs [get_multilibs]
66 }
67
68 proc libgomp_init { args } {
69 global srcdir blddir objdir tool_root_dir
70 global libgomp_initialized
71 global tmpdir
72 global gluefile wrap_flags
73 global ALWAYS_CFLAGS
74 global CFLAGS
75 global TOOL_EXECUTABLE TOOL_OPTIONS
76 global GCC_UNDER_TEST GXX_UNDER_TEST GFORTRAN_UNDER_TEST
77 global TESTING_IN_BUILD_TREE
78 global target_triplet
79 global always_ld_library_path
80
81 set blddir [lookfor_file [get_multilibs] libgomp]
82
83 # We set LC_ALL and LANG to C so that we get the same error
84 # messages as expected.
85 setenv LC_ALL C
86 setenv LANG C
87
88 # Many hosts now default to a non-ASCII C locale, however, so
89 # they can set a charset encoding here if they need.
90 if { [ishost "*-*-cygwin*"] } {
91 setenv LC_ALL C.ASCII
92 setenv LANG C.ASCII
93 }
94
95 if ![info exists GCC_UNDER_TEST] then {
96 if [info exists TOOL_EXECUTABLE] {
97 set GCC_UNDER_TEST $TOOL_EXECUTABLE
98 } else {
99 set GCC_UNDER_TEST "[find_gcc]"
100 }
101 # Only if we're guessing 'GCC_UNDER_TEST', we're also going to guess
102 # 'GXX_UNDER_TEST', 'GFORTRAN_UNDER_TEST'.
103 if ![info exists GXX_UNDER_TEST] then {
104 if [info exists TOOL_EXECUTABLE] {
105 set GXX_UNDER_TEST $TOOL_EXECUTABLE
106 } else {
107 set GXX_UNDER_TEST "[find_g++]"
108 }
109 } else {
110 error "GXX_UNDER_TEST set but not GCC_UNDER_TEST"
111 }
112 if ![info exists GFORTRAN_UNDER_TEST] then {
113 if [info exists TOOL_EXECUTABLE] {
114 set GFORTRAN_UNDER_TEST $TOOL_EXECUTABLE
115 } else {
116 set GFORTRAN_UNDER_TEST "[find_gfortran]"
117 }
118 } else {
119 error "GFORTRAN_UNDER_TEST set but not GCC_UNDER_TEST"
120 }
121 }
122
123 if ![info exists tmpdir] {
124 set tmpdir "/tmp"
125 }
126
127 if [info exists gluefile] {
128 unset gluefile
129 }
130
131 if {![info exists CFLAGS]} {
132 set CFLAGS ""
133 }
134
135 # Locate libgcc.a so we don't need to account for different values of
136 # SHLIB_EXT on different platforms
137 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
138 if {$gccdir != ""} {
139 set gccdir [file dirname $gccdir]
140 }
141
142 # Compute what needs to be put into LD_LIBRARY_PATH
143 set always_ld_library_path "."
144
145 global offload_additional_lib_paths
146 if { $offload_additional_lib_paths != "" } {
147 append always_ld_library_path "${offload_additional_lib_paths}"
148 }
149
150 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
151 if {$gccdir != ""} {
152 # Add AIX pthread directory first.
153 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
154 append always_ld_library_path ":${gccdir}/pthread"
155 }
156 append always_ld_library_path ":${gccdir}"
157 set compiler [lindex $GCC_UNDER_TEST 0]
158
159 if { [is_remote host] == 0 && [which $compiler] != 0 } {
160 foreach i "[exec $compiler --print-multi-lib]" {
161 set mldir ""
162 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
163 set mldir [string trimright $mldir "\;@"]
164 if { "$mldir" == "." } {
165 continue
166 }
167 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
168 append always_ld_library_path ":${gccdir}/${mldir}"
169 }
170 }
171 }
172 }
173
174 set ALWAYS_CFLAGS ""
175 if { $blddir != "" } {
176 # If '--with-build-sysroot=[...]' was specified, use it for build-tree
177 # testing.
178 global SYSROOT_CFLAGS_FOR_TARGET
179 lappend ALWAYS_CFLAGS "additional_flags=${SYSROOT_CFLAGS_FOR_TARGET}"
180
181 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
182 # targets that use libgomp.a%s in their specs need a -B option
183 # for uninstalled testing.
184 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
185 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
186 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
187
188 append always_ld_library_path ":${blddir}/.libs"
189 }
190 # The top-level include directory, for gomp-constants.h.
191 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include"
192 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
193
194 # For build-tree testing, also consider the library paths used for builing.
195 # For installed testing, we assume all that to be provided in the sysroot.
196 if { $blddir != "" } {
197 # The `-fopenacc' and `-fopenmp' options imply `-pthread', and
198 # that implies `-latomic' on some hosts, so wire in libatomic
199 # build directories.
200 if [ishost "riscv*-*-linux*"] {
201 set shlib_ext [get_shlib_extension]
202 set atomic_library_path "${blddir}/../libatomic/.libs"
203 if { [file exists "${atomic_library_path}/libatomic.a"]
204 || [file exists \
205 "${atomic_library_path}/libatomic.${shlib_ext}"] } {
206 lappend ALWAYS_CFLAGS \
207 "additional_flags=-L${atomic_library_path}"
208 append always_ld_library_path ":${atomic_library_path}"
209 }
210 }
211 }
212
213 # We use atomic operations in the testcases to validate results.
214 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
215 && [check_effective_target_ia32]
216 && ![check_effective_target_cas_char] } {
217 lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
218 }
219
220 if [istarget *-*-darwin*] {
221 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
222 }
223
224 if [istarget sparc*-*-*] {
225 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
226 }
227
228 if [info exists TOOL_OPTIONS] {
229 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
230 }
231
232 # Make sure that lines are not wrapped. That can confuse the
233 # error-message parsing machinery.
234 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
235
236 # Disable caret, color, URL diagnostics
237 lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-plain-output"
238
239 # Help GCC to find offload compilers' 'mkoffload'.
240 global offload_additional_options
241 if { $offload_additional_options != "" } {
242 lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
243 }
244
245 # Tell warning from error diagnostics. This fits for C, C++, and Fortran.
246 global gcc_warning_prefix
247 set gcc_warning_prefix "\[Ww\]arning:"
248 global gcc_error_prefix
249 set gcc_error_prefix "(\[Ff\]atal )?\[Ee\]rror:"
250 }
251
252 #
253 # libgomp_target_compile -- compile a source file
254 #
255
256 proc libgomp_target_compile { source dest type options } {
257 global blddir
258 global libgomp_compile_options
259 global gluefile wrap_flags
260 global ALWAYS_CFLAGS
261 global GCC_UNDER_TEST
262
263 global lang_source_re lang_include_flags
264 if { [info exists lang_include_flags] \
265 && [regexp ${lang_source_re} ${source}] } {
266 lappend options "additional_flags=${lang_include_flags}"
267 }
268
269 global lang_library_paths
270 if { [info exists lang_library_paths] } {
271 foreach lang_library_path $lang_library_paths {
272 # targets that use lib[...].a%s in their specs need a -B option
273 # for uninstalled testing.
274 lappend options "additional_flags=-B${blddir}/${lang_library_path}"
275 lappend options "ldflags=-L${blddir}/${lang_library_path}"
276 }
277 }
278 global lang_link_flags
279 if { [info exists lang_link_flags] } {
280 lappend options "ldflags=${lang_link_flags}"
281 }
282
283 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
284 lappend options "libs=${gluefile}"
285 lappend options "ldflags=${wrap_flags}"
286 }
287
288 lappend options "additional_flags=[libio_include_flags]"
289 lappend options "timeout=[timeout_value]"
290
291 set options [concat $libgomp_compile_options $options]
292
293 if [info exists ALWAYS_CFLAGS] {
294 set options [concat "$ALWAYS_CFLAGS" $options]
295 }
296
297 set options [dg-additional-files-options $options $source $dest $type]
298
299 set result [target_compile $source $dest $type $options]
300
301 return $result
302 }
303
304 proc libgomp_option_help { } {
305 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
306 }
307
308 proc libgomp_option_proc { option } {
309 if [regexp "^--additional_options," $option] {
310 global libgomp_compile_options
311 regsub "--additional_options," $option "" option
312 foreach x [split $option ","] {
313 lappend libgomp_compile_options "additional_flags=$x"
314 }
315 return 1
316 } else {
317 return 0
318 }
319 }
320
321 if ![info exists ::env(GCC_RUNTEST_PARALLELIZE_DIR)] {
322 # No parallel testing.
323 } elseif { $FLOCK == "" } {
324 # Using just one parallel slot.
325 } else {
326 # Using several parallel slots. Override DejaGnu
327 # 'standard.exp:${tool}_load'...
328 rename libgomp_load standard_libgomp_load
329 proc libgomp_load { program args } {
330 # ... in order to serialize execution testing via an exclusive lock.
331 # We use stdout, as per <https://perldoc.perl.org/functions/flock>
332 # "[...] FILEHANDLE [...] be open with write intent to use LOCK_EX".
333 set lock_file ../lock
334 set lock_kind --exclusive
335 set lock_fd [open $lock_file a+]
336 set lock_clock_begin [clock seconds]
337 global FLOCK
338 exec $FLOCK $lock_kind 1 >@ $lock_fd
339 set lock_clock_end [clock seconds]
340 verbose -log "Got ${FLOCK}('$lock_file', '$lock_kind') at [clock format $lock_clock_end] after [expr $lock_clock_end - $lock_clock_begin] s" 2
341
342 set result [standard_libgomp_load $program $args]
343
344 # Unlock (implicit with 'close').
345 close $lock_fd
346
347 return $result
348 }
349 }
350
351 # Translate offload target to OpenACC device type. Return the empty string if
352 # not supported, and 'host' for offload target 'disable'.
353 proc offload_target_to_openacc_device_type { offload_target } {
354 switch -glob $offload_target {
355 amdgcn* {
356 return "radeon"
357 }
358 disable {
359 return "host"
360 }
361 nvptx* {
362 return "nvidia"
363 }
364 default {
365 error "Unknown offload target: $offload_target"
366 }
367 }
368 }
369
370 # Return 1 if certain nonstandard math functions are available
371 # on the target: gamma, scalb, significand, and their float variants.
372 proc check_effective_target_nonstandard_math_functions { } {
373 return [check_no_compiler_messages nonstandard_math_functions executable {
374 #include <math.h>
375 int main() {
376 float x = 42;
377 double y = 42;
378 x = gammaf (x);
379 x = __builtin_scalbf (x, 2.f);
380 x =__builtin_significandf (x);
381 y = gamma (y);
382 y = __builtin_scalb (y, 2.);
383 y =__builtin_significand (y);
384 return 0;
385 }
386 } "-lm" ]
387 }
388
389 # Return 1 if compiling for the specified offload target
390 # Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES=
391 # in the -v compiler output.
392 proc libgomp_check_effective_target_offload_target { target_name } {
393 # Consider all actual options, including the flags passed to
394 # 'gcc-dg-runtest', or 'gfortran-dg-runtest' (see the 'libgomp.*/*.exp'
395 # files; in particular, '-foffload', 'libgomp.oacc-*/*.exp'), which don't
396 # get passed on to 'check_effective_target_*' functions. (Not caching the
397 # result due to that.)
398 set options [list "additional_flags=[concat "-v" [current_compiler_flags]]"]
399 # Instead of inspecting command-line options, look what the compiler driver
400 # decides. This is somewhat modelled after
401 # 'gcc/testsuite/lib/target-supports.exp:check_configured_with'.
402 set gcc_output [libgomp_target_compile "" "" "none" $options]
403 if [regexp "(?n)^OFFLOAD_TARGET_NAMES=(.*)" $gcc_output dummy gcc_offload_targets] {
404 verbose "compiling for offload targets: $gcc_offload_targets"
405 return [string match "*:$target_name*:*" ":$gcc_offload_targets:"]
406 }
407
408 verbose "not compiling for $target_name offload target"
409 return 0
410 }
411
412 # Return 1 if compiling for any offload target.
413 proc check_effective_target_offload_target_any { } {
414 return [libgomp_check_effective_target_offload_target ""]
415 }
416
417 # Return 1 if compiling for offload target nvptx.
418 proc check_effective_target_offload_target_nvptx { } {
419 return [libgomp_check_effective_target_offload_target "nvptx"]
420 }
421
422 # Return 1 if compiling for offload target amdgcn
423 proc check_effective_target_offload_target_amdgcn { } {
424 return [libgomp_check_effective_target_offload_target "amdgcn"]
425 }
426
427 # Return 1 if offload device is available.
428 proc check_effective_target_offload_device { } {
429 return [check_runtime_nocache offload_device_available_ {
430 #include <omp.h>
431 int main ()
432 {
433 int a;
434 #pragma omp target map(from: a)
435 a = omp_is_initial_device ();
436 return a;
437 }
438 } ]
439 }
440
441 # Return 1 if offload device is available and it has non-shared address space.
442 proc check_effective_target_offload_device_nonshared_as { } {
443 return [check_runtime_nocache offload_device_nonshared_as {
444 int main ()
445 {
446 int a = 8;
447 #pragma omp target map(to: a)
448 a++;
449 return a != 8;
450 }
451 } ]
452 }
453
454 # Return 1 if offload device is available and it has shared address space.
455 proc check_effective_target_offload_device_shared_as { } {
456 return [check_runtime_nocache offload_device_shared_as {
457 int main ()
458 {
459 int x = 10;
460 #pragma omp target map(to: x)
461 x++;
462 return x == 10;
463 }
464 } ]
465 }
466
467 # Return 1 if using nvptx offload device.
468 proc check_effective_target_offload_device_nvptx { } {
469 return [check_runtime_nocache offload_device_nvptx {
470 #include <omp.h>
471 #include "testsuite/libgomp.c-c++-common/on_device_arch.h"
472 int main ()
473 {
474 return !on_device_arch_nvptx ();
475 }
476 } ]
477 }
478
479 # Return 1 if using a GCN offload device.
480 proc check_effective_target_offload_device_gcn { } {
481 return [check_runtime_nocache offload_device_gcn {
482 #include <omp.h>
483 #include "testsuite/libgomp.c-c++-common/on_device_arch.h"
484 int main ()
485 {
486 return !on_device_arch_gcn ();
487 }
488 } ]
489 }
490
491 # Return 1 if at least one Nvidia GPU is accessible.
492
493 proc check_effective_target_openacc_nvidia_accel_present { } {
494 return [check_runtime openacc_nvidia_accel_present {
495 #include <openacc.h>
496 int main () {
497 return !(acc_get_num_devices (acc_device_nvidia) > 0);
498 }
499 } "" ]
500 }
501
502 # Return 1 if at least one Nvidia GPU is accessible, and the OpenACC 'nvidia'
503 # device type is selected.
504
505 proc check_effective_target_openacc_nvidia_accel_selected { } {
506 if { ![check_effective_target_openacc_nvidia_accel_present] } {
507 return 0;
508 }
509 global openacc_device_type
510 return [string match "nvidia" $openacc_device_type]
511 }
512
513 # Return 1 if the OpenACC 'host' device type is selected.
514
515 proc check_effective_target_openacc_host_selected { } {
516 global openacc_device_type
517 return [string match "host" $openacc_device_type]
518 }
519
520 # Return 1 if at least one AMD GPU is accessible.
521
522 proc check_effective_target_openacc_radeon_accel_present { } {
523 return [check_runtime openacc_radeon_accel_present {
524 #include <openacc.h>
525 int main () {
526 return !(acc_get_num_devices (acc_device_radeon) > 0);
527 }
528 } "" ]
529 }
530
531 # Return 1 if at least one AMD GPU is accessible, and the OpenACC 'radeon'
532 # device type is selected.
533
534 proc check_effective_target_openacc_radeon_accel_selected { } {
535 if { ![check_effective_target_openacc_radeon_accel_present] } {
536 return 0;
537 }
538 global openacc_device_type
539 return [string match "radeon" $openacc_device_type]
540 }
541
542 # Return 1 if cuda.h and -lcuda are available.
543
544 proc check_effective_target_openacc_cuda { } {
545 return [check_no_compiler_messages openacc_cuda executable {
546 #include <cuda.h>
547 int main() {
548 CUdevice dev;
549 CUresult r = cuDeviceGet (&dev, 0);
550 if (r != CUDA_SUCCESS)
551 return 1;
552 return 0;
553 } } "-lcuda" ]
554 }
555
556 # Return 1 if -lcuda is available (header not required).
557
558 proc check_effective_target_openacc_libcuda { } {
559 return [check_no_compiler_messages openacc_libcuda executable {
560 typedef enum { CUDA_SUCCESS } CUresult;
561 typedef int CUdevice;
562 CUresult cuDeviceGet (CUdevice *, int);
563 int main() {
564 CUdevice dev;
565 CUresult r = cuDeviceGet (&dev, 0);
566 if (r != CUDA_SUCCESS)
567 return 1;
568 return 0;
569 } } "-lcuda" ]
570 }
571
572 # Return 1 if cublas_v2.h, cuda.h, -lcublas and -lcuda are available.
573
574 proc check_effective_target_openacc_cublas { } {
575 return [check_no_compiler_messages openacc_cublas executable {
576 #include <cuda.h>
577 #include <cublas_v2.h>
578 int main() {
579 cublasStatus_t s;
580 cublasHandle_t h;
581 CUdevice dev;
582 CUresult r = cuDeviceGet (&dev, 0);
583 if (r != CUDA_SUCCESS)
584 return 1;
585 s = cublasCreate (&h);
586 if (s != CUBLAS_STATUS_SUCCESS)
587 return 1;
588 return 0;
589 } } "-lcuda -lcublas" ]
590 }
591
592 # Return 1 if -lcublas is available header not required).
593
594 proc check_effective_target_openacc_libcublas { } {
595 return [check_no_compiler_messages openacc_libcublas executable {
596 typedef enum { CUBLAS_STATUS_SUCCESS } cublasStatus_t;
597 typedef struct cublasContext* cublasHandle_t;
598 #define cublasCreate cublasCreate_v2
599 cublasStatus_t cublasCreate_v2 (cublasHandle_t *);
600 int main() {
601 cublasStatus_t s;
602 cublasHandle_t h;
603 s = cublasCreate (&h);
604 if (s != CUBLAS_STATUS_SUCCESS)
605 return 1;
606 return 0;
607 } } "-lcublas" ]
608 }
609
610 # Return 1 if cuda_runtime_api.h, cuda.h, -lcuda and -lcudart are available.
611
612 proc check_effective_target_openacc_cudart { } {
613 return [check_no_compiler_messages openacc_cudart executable {
614 #include <cuda.h>
615 #include <cuda_runtime_api.h>
616 int main() {
617 cudaError_t e;
618 int devn;
619 CUdevice dev;
620 CUresult r = cuDeviceGet (&dev, 0);
621 if (r != CUDA_SUCCESS)
622 return 1;
623 e = cudaGetDevice (&devn);
624 if (e != cudaSuccess)
625 return 1;
626 return 0;
627 } } "-lcuda -lcudart" ]
628 }
629
630 # Return 1 if -lcudart is available (no header required).
631
632 proc check_effective_target_openacc_libcudart { } {
633 return [check_no_compiler_messages openacc_libcudart executable {
634 typedef int cudaError_t;
635 cudaError_t cudaGetDevice(int *);
636 enum { cudaSuccess };
637 int main() {
638 cudaError_t e;
639 int devn;
640 e = cudaGetDevice (&devn);
641 if (e != cudaSuccess)
642 return 1;
643 return 0;
644 } } "-lcudart" ]
645 }
646
647 # Return 1 if hip.h is available (no link check; AMD platform).
648
649 proc check_effective_target_gomp_hip_header_amd { } {
650 return [check_no_compiler_messages gomp_hip_header_amd assembly {
651 #define __HIP_PLATFORM_AMD__
652 #include <hip/hip_runtime_api.h>
653 int main() {
654 hipDevice_t dev;
655 hipError_t r = hipDeviceGet (&dev, 0);
656 if (r != hipSuccess)
657 return 1;
658 return 0;
659 } }]
660 }
661
662 # Return 1 if hip.h is available (no link check; Nvidia/CUDA platform).
663
664 proc check_effective_target_gomp_hip_header_nvidia { } {
665 return [check_no_compiler_messages gomp_hip_header_nvidia assembly {
666 #define __HIP_PLATFORM_NVIDIA__
667 #include <hip/hip_runtime_api.h>
668 int main() {
669 hipDevice_t dev;
670 hipError_t r = hipDeviceGet (&dev, 0);
671 if (r != hipSuccess)
672 return 1;
673 return 0;
674 } } "-Wno-deprecated-declarations"]
675 }
676
677 # Return 1 if the Fortran hipfort module is available (no link check)
678
679 proc check_effective_target_gomp_hipfort_module { } {
680 return [check_no_compiler_messages gomp_hipfort_module assembly {
681 ! Fortran
682 use hipfort
683 implicit none
684 integer(kind(hipSuccess)) :: r
685 integer(c_int) :: dev
686 r = hipDeviceGet (dev, 0)
687 if (r /= hipSuccess) error stop
688 end
689 }]
690 }
691
692 # Return 1 if AMD HIP's -lamdhip64 is available (no header required).
693
694 proc check_effective_target_gomp_libamdhip64 { } {
695 return [check_no_compiler_messages gomp_libamdhip64 executable {
696 typedef int hipError_t;
697 typedef int hipDevice_t;
698 enum { hipSuccess = 0 };
699 hipError_t hipDeviceGet(hipDevice_t*, int);
700 int main() {
701 hipDevice_t dev;
702 hipError_t r = hipDeviceGet (&dev, 0);
703 if (r != hipSuccess)
704 return 1;
705 return 0;
706 } } "-lamdhip64" ]
707 }
708
709 # Return 1 if AMD HIP's -lamdhip64 is available (no header required).
710
711 proc check_effective_target_gomp_libhipblas { } {
712 return [check_no_compiler_messages gomp_libhipblas executable {
713 typedef enum { HIPBLAS_STATUS_SUCCESS = 0 } hipblasStatus_t;
714 typedef void* hipblasHandle_t;
715 hipblasStatus_t hipblasCreate (hipblasHandle_t*);
716 int main() {
717 hipblasHandle_t handle;
718 hipblasStatus_t stat = hipblasCreate (&handle);
719 if (stat != HIPBLAS_STATUS_SUCCESS)
720 return 1;
721 return 0;
722 } } "-lhipblas" ]
723 }