Skip to content

Commit 3ae0598

Browse files
authored
Merge pull request #34 from ajarmusch/acc_malloc
New FTN Routine: acc_malloc
2 parents 24c7725 + 4bcdb52 commit 3ae0598

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

Tests/acc_malloc.F90

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#ifndef T1
2+
!T1:runtime,construct-independent,internal-control-values,init,nonvalidating,V:3.3
3+
LOGICAL FUNCTION test1()
4+
USE OPENACC
5+
IMPLICIT NONE
6+
INCLUDE "acc_testsuite.Fh"
7+
REAL(8),DIMENSION(LOOPCOUNT):: initial_memory, final_memory !Data
8+
INTEGER, POINTER :: a(:)
9+
INTEGER :: errors = 0
10+
11+
initial_memory = acc_get_property(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_free_memory)
12+
13+
acc_malloc(a(N))
14+
15+
IF (initial_memory .ne. 0) THEN
16+
test1 = .FALSE.
17+
END IF
18+
19+
final_memory = acc_get_property(acc_get_device_num(acc_get_device_type()), acc_get_device_type(), acc_property_free_memory)
20+
21+
DO x = 1, LOOPCOUNT
22+
IF (final_memory + N * sizeof(a(1)) .gt. initial_memory) THEN
23+
errors = errors + 1
24+
END IF
25+
END DO
26+
27+
acc_free(a(N))
28+
29+
IF (errors .eq. 0) THEN
30+
test1 = .FALSE.
31+
ELSE
32+
test1 = .TRUE.
33+
END IF
34+
END
35+
#endif
36+
37+
PROGRAM main
38+
IMPLICIT NONE
39+
INTEGER :: failcode, testrun
40+
LOGICAL :: failed
41+
INCLUDE "acc_testsuite.Fh"
42+
!Conditionally define test functions
43+
#ifndef T1
44+
LOGICAL :: test1
45+
#endif
46+
failcode = 0
47+
failed = .FALSE.
48+
49+
#ifndef T1
50+
DO testrun = 1, NUM_TEST_CALLS
51+
failed = failed .or. test1()
52+
END DO
53+
IF (failed) THEN
54+
failcode = failcode + 2 ** 0
55+
failed = .FALSE.
56+
END IF
57+
#endif
58+
CALL EXIT (failcode)
59+
END PROGRAM
60+
61+

0 commit comments

Comments
 (0)