Skip to content

Commit e47b080

Browse files
committed
Add support-test/out_of_memory
1 parent 8064702 commit e47b080

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ jobs:
289289
CAF_IMAGES=$(( CAF_IMAGES / 2 )) ; \
290290
done
291291
292-
- name: Run exit tests
292+
- name: Run exit/failure tests
293293
run: |
294294
echo CAF_IMAGES=${CAF_IMAGES}
295295
set -x
@@ -301,6 +301,14 @@ jobs:
301301
./run-fpm.sh run --verbose --example fail_image 2>&1 | tee output ; \
302302
test ${PIPESTATUS[0]} > 0 && grep -q "FAIL IMAGE" output \
303303
)
304+
( set +e ; \
305+
./run-fpm.sh run --verbose --example out_of_memory 2>&1 | tee output ; \
306+
test ${PIPESTATUS[0]} > 0 && grep -q "out of memory" output \
307+
)
308+
( set +e ; \
309+
./run-fpm.sh run --verbose --example out_of_memory -- --coarray 2>&1 | tee output ; \
310+
test ${PIPESTATUS[0]} > 0 && grep -q "out of memory" output \
311+
)
304312
unset GASNET_SPAWN_VERBOSE
305313
for ((i=1; i<=4; i++)); do \
306314
(set +e ; \
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
program out_of_memory
2+
use iso_c_binding, only: c_bool, c_size_t, c_ptr, c_null_funptr, c_int64_t
3+
use prif
4+
implicit none
5+
6+
integer :: init_exit_code, me, i
7+
integer(c_size_t) :: size_in_bytes = ishft(500_c_size_t, 40)
8+
type(c_ptr) :: allocated_memory
9+
logical :: coarray = .false.
10+
character(len=256) :: arg
11+
12+
call prif_init(init_exit_code)
13+
if (init_exit_code /= 0 .and. init_exit_code /= PRIF_STAT_ALREADY_INIT) then
14+
call prif_error_stop(quiet=.false._c_bool, stop_code_char="program startup failed")
15+
end if
16+
call prif_this_image_no_coarray(this_image=me)
17+
18+
do i = 1, command_argument_count()
19+
call get_command_argument(i, arg)
20+
21+
if (trim(arg) == "--coarray" .or. trim(arg) == "-c") then
22+
coarray = .true.
23+
else
24+
read(arg, *) size_in_bytes
25+
end if
26+
end do
27+
28+
if (coarray) then
29+
if (me == 1) print *, "prif_allocate_coarray: ", size_in_bytes, " bytes"
30+
block
31+
integer(c_int64_t), dimension(1) :: lcobounds, ucobounds
32+
integer :: num_imgs
33+
type(prif_coarray_handle) :: coarray_handle
34+
35+
call prif_num_images(num_images=num_imgs)
36+
lcobounds(1) = 1
37+
ucobounds(1) = num_imgs
38+
39+
call prif_allocate_coarray( &
40+
lcobounds, ucobounds, size_in_bytes, c_null_funptr, &
41+
coarray_handle, allocated_memory)
42+
end block
43+
else
44+
if (me == 1) print *, "prif_allocate: ", size_in_bytes, " bytes"
45+
call prif_sync_all()
46+
call prif_allocate(size_in_bytes, allocated_memory)
47+
end if
48+
49+
50+
call prif_sync_all()
51+
call prif_error_stop(quiet=.false._c_bool, stop_code_char="test failed")
52+
53+
end program

0 commit comments

Comments
 (0)