Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix pure Fypp macros #36

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions example/coarray-fypp/test_simple_fypp.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ contains
!> Broadcast test with collective communication
!!
!! Note: as coarray parallelism might be implemented via threads, coarray tests must be "pure" and
!! use the passed context object to signalize test events. The Fypp macros automaticaly handle
!! this (using "ctx" as name for the context instance).
!! use a passed context object to signalize test events. The Fypp macros below automaticaly handle
!! this (using the configurable name "ctx" for the context instance).
!!
$:TEST("broadcast")
$:PURE_TEST("broadcast")
integer, parameter :: sourceimg = 1, sourceval = 100, otherval = -1
integer :: buffer

Expand All @@ -38,16 +38,16 @@ contains

! THEN each image must contain source image's value
!
! Note: CHECK() and ASSERT() calls are collective calls, all images must call them with their
! local result synchronously.
! Note: PURE_CHECK() and PURE_ASSERT() calls are collective calls, all images must call them
! with their local result synchronously.
!
@:CHECK(is_equal(buffer, sourceval), msg=msg)
@:PURE_CHECK(is_equal(buffer, sourceval), msg=msg)

$:END_TEST()
$:END_PURE_TEST()


!> Broadcast test with collective communication
$:TEST("broadcast_fail3")
$:PURE_TEST("broadcast_fail3")
integer, parameter :: sourceimg = 1, sourceval = 100, otherval = -1
integer :: buffer

Expand Down Expand Up @@ -75,9 +75,9 @@ contains
! ASSERT() causes the test code to return immediately, while CHECK() only logs the failure and
! continues.
!
@:ASSERT(is_equal(buffer, sourceval), msg=msg)
@:PURE_ASSERT(is_equal(buffer, sourceval), msg=msg)

$:END_TEST()
$:END_PURE_TEST()


! Returns the test items from this module
Expand Down
10 changes: 5 additions & 5 deletions include/fortuno_coarray.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#! ctxvar: name of the context dummy argument
#! args: Arguments of the test procedure as a list of strings
#!
#:def TEST(name, label="", ctxtype="class(coa_context)", ctxvar="ctx", args=None)
#:def PURE_TEST(name, label="", ctxtype="class(coa_context)", ctxvar="ctx", args=None)
#:set proc = "test" + ("_" + label if label else "") + "_" + name
#:set allargs = [ctxvar] if args is None else [ctxvar]+ args
#:set argstr = ", ".join(allargs)
Expand All @@ -37,7 +37,7 @@


#! Ends a test procedure
#:def END_TEST()
#:def END_PURE_TEST()
end subroutine
#:enddef

Expand Down Expand Up @@ -68,7 +68,7 @@
#! ctxvar: Name of the context variable
#! **kwargs: any keyword arguments, which should be passed to mpi_check()
#!
#:def CHECK(cond, ctxvar="ctx", **kwargs)
#:def PURE_CHECK(cond, ctxvar="ctx", **kwargs)
#:if kwargs
#:set kwargstr = ", ".join([f"{name}={value}" for name, value in kwargs.items()])
call ${ctxvar}$%check(${cond}$, file="${_FILE_}$", line=${_LINE_}$, ${kwargstr}$)
Expand All @@ -84,8 +84,8 @@
#! cond: Condition to check
#! **kwargs: any keyword arguments, which should be passed to check()
#!
#:def ASSERT(cond, ctxvar="ctx", **kwargs)
$:CHECK(cond, ctxvar=ctxvar, **kwargs)
#:def PURE_ASSERT(cond, ctxvar="ctx", **kwargs)
$:PURE_CHECK(cond, ctxvar=ctxvar, **kwargs)
if (${ctxvar}$%check_failed()) return
#:enddef

Expand Down
6 changes: 3 additions & 3 deletions test/export/coarray/app/testapp_fypp.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ module testapp_coa_fypp_tests
contains


$:TEST("success")
$:PURE_TEST("success")

integer :: buffer

buffer = 0
if (this_image() == 1) buffer = 1
call co_broadcast(buffer, 1)
@:CHECK(is_equal(buffer, 1))
@:PURE_CHECK(is_equal(buffer, 1))

$:END_TEST()
$:END_PURE_TEST()


function tests()
Expand Down
Loading