-
Notifications
You must be signed in to change notification settings - Fork 25
Let OMPVV_TEST_VERBOSE print condition #894
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
base: master
Are you sure you want to change the base?
Let OMPVV_TEST_VERBOSE print condition #894
Conversation
Just printing "condition" is useless. Actually print the condition being tested. Before: [header test_target_map_components_default.F90:111] Condition condition failed After: [header test_target_map_components_default.F90:110] Condition .NOT. ASSOCIATED(myStruct(i). yPtr, justATarget) failed
|
@andrewkallai , can you test this ? |
andrewkallai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will not compile when compiling with gfortran
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:30:73:
30 | OMPVV_TEST_VERBOSE(test_map_derived_type_default() .ne. 0)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:31:79:
31 | OMPVV_TEST_VERBOSE(test_map_derived_type_default_array() .ne. 0)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:63:59:
63 | OMPVV_TEST_VERBOSE(cpyStruct%myInt /= 5)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:64:74:
64 | OMPVV_TEST_VERBOSE(cpyStruct%myStr .NE. 'there you go')
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:65:78:
65 | OMPVV_TEST_VERBOSE(ABS(cpyStruct%myReal - 4.4) .GT. 0.0001)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:66:65:
66 | OMPVV_TEST_VERBOSE(ANY(cpyStruct%myArr /= 10))
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:67:84:
67 | OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(myStruct%myPtr, justATarget))
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:68:85:
68 | OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(cpyStruct%myPtr, justATarget))
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:106:64:
106 | OMPVV_TEST_VERBOSE(cpyStruct(i)%myInt /= 5)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:107:79:
107 | OMPVV_TEST_VERBOSE(cpyStruct(i)%myStr .NE. 'there you go')
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:108:83:
108 | OMPVV_TEST_VERBOSE(ABS(cpyStruct(i)%myReal - 4.4) .GT. 0.0001)
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:109:70:
109 | OMPVV_TEST_VERBOSE(ANY(cpyStruct(i)%myArr /= 10))
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:110:89:
110 | OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(myStruct(i)%myPtr, justATarget))
| 1
Error: Syntax error in argument list at (1)
/storage/users/andrewka/OpenMP_VV/tests/4.5/target/test_target_map_components_default.F90:111:90:
111 | OMPVV_TEST_VERBOSE(.NOT. ASSOCIATED(cpyStruct(i)%myPtr, justATarget))
| 1
Error: Syntax error in argument list at (1)
As such, a preprocessor conitional has to be added to check if gfortran is being used.
|
|
||
| ! Macro for testing for errors | ||
| #define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, "condition", __FILENAME__, __LINE__) | ||
| #define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__) | |
| #ifdef __GFORTRAN__ | |
| #define STR(x) "x" | |
| #define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, STR(condition), __FILENAME__, __LINE__) | |
| #else | |
| #define OMPVV_TEST_VERBOSE(condition) call test_error_verbose(condition, #condition, __FILENAME__, __LINE__) | |
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change line 86 to
#ifdef __GFORTRAN__
#define STR(x) "x"
#define OMPVV_TEST_AND_SET_VERBOSE(err, condition) err = err + test_and_set_verbose(condition, STR(condition), __FILENAME__, __LINE__)
#else
#define OMPVV_TEST_AND_SET_VERBOSE(err, condition) err = err + test_and_set_verbose(condition, #condition, __FILENAME__, __LINE__)
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewkallai Can you try whether changing #condition to "condition " #condition works for gfortran and other compilers? The preprocessor is supposed to expand #condition to the value of condition wrapped in double quotes, and then the resulting constant is concatenated with the adjacent string constant. As I know the concatenation is optional, but let's try whether this trick works or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GNU cpp's manual suggests a way to stringize using the traditional cpp:

It indeed seems to work: https://godbolt.org/z/jWKGrnffc
|
Updated PR to supprot GFortran's traditional cpp. Instead of #define suffix(x) foo_/**/x
#define foo_bar 1
#define foo_
#define bar 0
#if suffix(bar)
Running in Traditional Mode
#else
Running in Standard Mode
#endif |
Just printing "condition" is useless. Actually print the condition being tested.
Before:
After: