| 1 |
|
| 2 |
README for the OpenMP Tooling Interface Testing Library (ompTest) |
| 3 |
================================================================= |
| 4 |
|
| 5 |
# Introduction |
| 6 |
OpenMP Tooling Interface Testing Library (ompTest) |
| 7 |
ompTest is a unit testing framework for testing OpenMP implementations. |
| 8 |
It offers a simple-to-use framework that allows a tester to check for OMPT |
| 9 |
events in addition to regular unit testing code, supported by linking against |
| 10 |
GoogleTest by default. It also facilitates writing concise tests while bridging |
| 11 |
the semantic gap between the unit under test and the OMPT-event testing. |
| 12 |
|
| 13 |
# Testing macros |
| 14 |
|
| 15 |
Corresponding macro definitions are located in: `./include/AssertMacros.h` |
| 16 |
|
| 17 |
## OMPT_GENERATE_EVENTS(NumberOfCopies, EventMacro) |
| 18 |
`TODO` |
| 19 |
|
| 20 |
## OMPT_ASSERT_SET_EVENT(Name, Group, EventTy, ...) |
| 21 |
`TODO` |
| 22 |
|
| 23 |
## OMPT_ASSERT_SET(EventTy, ...) |
| 24 |
`TODO` |
| 25 |
|
| 26 |
## OMPT_ASSERT_SET_GROUPED(Group, EventTy, ...) |
| 27 |
`TODO` |
| 28 |
|
| 29 |
## OMPT_ASSERT_SET_NAMED(Name, EventTy, ...) |
| 30 |
`TODO` |
| 31 |
|
| 32 |
## OMPT_ASSERT_SET_EVENT_NOT(Name, Group, EventTy, ...) |
| 33 |
`TODO` |
| 34 |
|
| 35 |
## OMPT_ASSERT_SET_NOT(EventTy, ...) |
| 36 |
`TODO` |
| 37 |
|
| 38 |
## OMPT_ASSERT_SET_GROUPED_NOT(Group, EventTy, ...) |
| 39 |
`TODO` |
| 40 |
|
| 41 |
## OMPT_ASSERT_SET_NAMED_NOT(Name, EventTy, ...) |
| 42 |
`TODO` |
| 43 |
|
| 44 |
## OMPT_ASSERT_SEQUENCE_EVENT(Name, Group, EventTy, ...) |
| 45 |
`TODO` |
| 46 |
|
| 47 |
## OMPT_ASSERT_SEQUENCE(EventTy, ...) |
| 48 |
This macro checks for the occurrence of the provided event, which also |
| 49 |
entails the exact sequence of events. When only using this assertion macro one |
| 50 |
has to provide every single event in the exact order of occurrence. |
| 51 |
|
| 52 |
## OMPT_ASSERT_SEQUENCE_GROUPED(Group, EventTy, ...) |
| 53 |
This macro acts like `OMPT_ASSERT_SEQUENCE` with the addition of grouping. |
| 54 |
|
| 55 |
## OMPT_ASSERT_SEQUENCE_NAMED(Name, EventTy, ...) |
| 56 |
`TODO` |
| 57 |
|
| 58 |
## OMPT_ASSERT_SEQUENCE_EVENT_NOT(Name, Group, EventTy, ...) |
| 59 |
`TODO` |
| 60 |
|
| 61 |
## OMPT_ASSERT_SEQUENCE_NOT(EventTy, ...) |
| 62 |
`TODO` |
| 63 |
|
| 64 |
## OMPT_ASSERT_SEQUENCE_GROUPED_NOT(Group, EventTy, ...) |
| 65 |
`TODO` |
| 66 |
|
| 67 |
## OMPT_ASSERT_SEQUENCE_NAMED_NOT(Name, EventTy, ...) |
| 68 |
`TODO` |
| 69 |
|
| 70 |
## OMPT_ASSERT_SEQUENCE_SUSPEND() |
| 71 |
`TODO` |
| 72 |
|
| 73 |
## OMPT_ASSERT_SEQUENCE_ONLY(EventTy, ...) |
| 74 |
This macro acts like `OMPT_ASSERT_SEQUENCE`, while actually being preceded |
| 75 |
-AND- succeeded by commands to suspend sequenced assertion until the next match. |
| 76 |
As a result, one may omit all other "unnecessary" events from the sequence. |
| 77 |
|
| 78 |
## OMPT_ASSERT_SEQUENCE_GROUPED_ONLY(Group, EventTy, ...) |
| 79 |
This macro acts like `OMPT_ASSERT_SEQUENCE_ONLY`, plus grouping. |
| 80 |
|
| 81 |
## OMPT_ASSERT_SEQUENCE_NAMED_ONLY(Name, EventTy, ...) |
| 82 |
`TODO` |
| 83 |
|
| 84 |
## OMPT_ASSERTER_MODE_STRICT(Asserter) |
| 85 |
`TODO` |
| 86 |
|
| 87 |
## OMPT_ASSERTER_MODE_RELAXED(Asserter) |
| 88 |
`TODO` |
| 89 |
|
| 90 |
## OMPT_ASSERT_SEQUENCE_MODE_STRICT() |
| 91 |
`TODO` |
| 92 |
|
| 93 |
## OMPT_ASSERT_SEQUENCE_MODE_RELAXED() |
| 94 |
`TODO` |
| 95 |
|
| 96 |
## OMPT_ASSERT_SET_MODE_STRICT() |
| 97 |
`TODO` |
| 98 |
|
| 99 |
## OMPT_ASSERT_SET_MODE_RELAXED() |
| 100 |
`TODO` |
| 101 |
|
| 102 |
## OMPT_ASSERTER_DISABLE(Asserter) |
| 103 |
`TODO` |
| 104 |
|
| 105 |
## OMPT_ASSERTER_ENABLE(Asserter) |
| 106 |
`TODO` |
| 107 |
|
| 108 |
## OMPT_ASSERT_SET_DISABLE() |
| 109 |
`TODO` |
| 110 |
|
| 111 |
## OMPT_ASSERT_SET_ENABLE() |
| 112 |
`TODO` |
| 113 |
|
| 114 |
## OMPT_ASSERT_SEQUENCE_DISABLE() |
| 115 |
`TODO` |
| 116 |
|
| 117 |
## OMPT_ASSERT_SEQUENCE_ENABLE() |
| 118 |
`TODO` |
| 119 |
|
| 120 |
## OMPT_REPORT_EVENT_DISABLE() |
| 121 |
`TODO` |
| 122 |
|
| 123 |
## OMPT_REPORT_EVENT_ENABLE() |
| 124 |
`TODO` |
| 125 |
|
| 126 |
## OMPT_ASSERTER_PERMIT_EVENT(Asserter, EventTy) |
| 127 |
`TODO` |
| 128 |
|
| 129 |
## OMPT_ASSERTER_SUPPRESS_EVENT(Asserter, EventTy) |
| 130 |
`TODO` |
| 131 |
|
| 132 |
## OMPT_PERMIT_EVENT(EventTy) |
| 133 |
`TODO` |
| 134 |
|
| 135 |
## OMPT_SUPPRESS_EVENT(EventTy) |
| 136 |
`TODO` |
| 137 |
|
| 138 |
## OMPT_ASSERTER_LOG_LEVEL(Asserter, LogLevel) |
| 139 |
`TODO` |
| 140 |
|
| 141 |
## OMPT_ASSERTER_LOG_FORMATTED(Asserter, FormatLog) |
| 142 |
`TODO` |
| 143 |
|
| 144 |
## OMPT_ASSERT_SYNC_POINT(SyncPointName) |
| 145 |
`TODO` |
| 146 |
|
| 147 |
### Grouping Asserts |
| 148 |
|
| 149 |
This allows to generate and verify data during runtime of a test. |
| 150 |
Currently, we only use target region information which manifests into groups. |
| 151 |
This allows to correlate multiple events to a certain target region without |
| 152 |
manual interaction just by specifying a groupname for these events. |
| 153 |
|
| 154 |
When a target region is encountered and we are about to enter it, we gather the |
| 155 |
`target_id` (non-EMI) -OR- `target_data->value` (EMI). This value is stored |
| 156 |
along the groupname for future reference. Upon target region end, the |
| 157 |
corresponding group is erased. (Note: The groupname is available again.) |
| 158 |
|
| 159 |
Other asserted callbacks which may occur within target regions query their |
| 160 |
groupname: retrieving and comparing the value of the group against the observed |
| 161 |
event's value. |
| 162 |
|
| 163 |
### Suspending Sequenced Asserts |
| 164 |
|
| 165 |
When a sequence of events is not of interest while testing, these additional |
| 166 |
events may be ignored by suspending the assertion until the next match. This |
| 167 |
can be done by using `OMPT_ASSERT_SEQUENCE_SUSPEND` manually or the `_ONLY` |
| 168 |
macro variants, like `OMPT_ASSERT_GROUPED_SEQUENCE_ONLY`. |
| 169 |
|
| 170 |
The former adds a special event to the queue of expected events and signal |
| 171 |
that any non-matching event should be ignored rather than failing the test. |
| 172 |
`_ONLY` macros embed their corresponding macro between two calls to |
| 173 |
`OMPT_ASSERT_SEQUENCE_SUSPEND`. As a consequence, we enter passive assertion |
| 174 |
until a match occurs, then enter passive assertion again. This enables us to |
| 175 |
"only" assert a certain, single event in arbitrary circumstances. |
| 176 |
|
| 177 |
### Asserter Modes |
| 178 |
`TODO` |
| 179 |
|
| 180 |
## Aliases (shorthands) |
| 181 |
To allow for easier writing of tests and enhanced readability, the following set |
| 182 |
of aliases is introduced. The left hand side represents the original value, |
| 183 |
while the right hand side depicts the shorthand version. |
| 184 |
|
| 185 |
| Type | Enum Value | Shorthand | |
| 186 |
|---------------------------|---------------------------------------------|---------------------------| |
| 187 |
| **ompt_scope_endpoint_t** | | | |
| 188 |
| | ompt_scope_begin | BEGIN | |
| 189 |
| | ompt_scope_end | END | |
| 190 |
| | ompt_scope_beginend | BEGINEND | |
| 191 |
| **ompt_target_t** | | | |
| 192 |
| | ompt_target | TARGET | |
| 193 |
| | ompt_target_enter_data | ENTER_DATA | |
| 194 |
| | ompt_target_exit_data | EXIT_DATA | |
| 195 |
| | ompt_target_update | UPDATE | |
| 196 |
| | ompt_target_nowait | TARGET_NOWAIT | |
| 197 |
| | ompt_target_enter_data_nowait | ENTER_DATA_NOWAIT | |
| 198 |
| | ompt_target_exit_data_nowait | EXIT_DATA_NOWAIT | |
| 199 |
| | ompt_target_update_nowait | UPDATE_NOWAIT | |
| 200 |
| **ompt_target_data_op_t** | | | |
| 201 |
| | ompt_target_data_alloc | ALLOC | |
| 202 |
| | ompt_target_data_transfer_to_device | H2D | |
| 203 |
| | ompt_target_data_transfer_from_device | D2H | |
| 204 |
| | ompt_target_data_delete | DELETE | |
| 205 |
| | ompt_target_data_associate | ASSOCIATE | |
| 206 |
| | ompt_target_data_disassociate | DISASSOCIATE | |
| 207 |
| | ompt_target_data_alloc_async | ALLOC_ASYNC | |
| 208 |
| | ompt_target_data_transfer_to_device_async | H2D_ASYNC | |
| 209 |
| | ompt_target_data_transfer_from_device_async | D2H_ASYNC | |
| 210 |
| | ompt_target_data_delete_async | DELETE_ASYNC | |
| 211 |
| **ompt_callbacks_t** | | | |
| 212 |
| | ompt_callback_target | CB_TARGET | |
| 213 |
| | ompt_callback_target_data_op | CB_DATAOP | |
| 214 |
| | ompt_callback_target_submit | CB_KERNEL | |
| 215 |
| **ompt_work_t** | | | |
| 216 |
| | ompt_work_loop | WORK_LOOP | |
| 217 |
| | ompt_work_sections | WORK_SECT | |
| 218 |
| | ompt_work_single_executor | WORK_EXEC | |
| 219 |
| | ompt_work_single_other | WORK_SINGLE | |
| 220 |
| | ompt_work_workshare | WORK_SHARE | |
| 221 |
| | ompt_work_distribute | WORK_DIST | |
| 222 |
| | ompt_work_taskloop | WORK_TASK | |
| 223 |
| | ompt_work_scope | WORK_SCOPE | |
| 224 |
| | ompt_work_loop_static | WORK_LOOP_STA | |
| 225 |
| | ompt_work_loop_dynamic | WORK_LOOP_DYN | |
| 226 |
| | ompt_work_loop_guided | WORK_LOOP_GUI | |
| 227 |
| | ompt_work_loop_other | WORK_LOOP_OTH | |
| 228 |
| **ompt_sync_region_t** | | | |
| 229 |
| | ompt_sync_region_barrier | SR_BARRIER | |
| 230 |
| | ompt_sync_region_barrier_implicit | SR_BARRIER_IMPL | |
| 231 |
| | ompt_sync_region_barrier_explicit | SR_BARRIER_EXPL | |
| 232 |
| | ompt_sync_region_barrier_implementation | SR_BARRIER_IMPLEMENTATION | |
| 233 |
| | ompt_sync_region_taskwait | SR_TASKWAIT | |
| 234 |
| | ompt_sync_region_taskgroup | SR_TASKGROUP | |
| 235 |
| | ompt_sync_region_reduction | SR_REDUCTION | |
| 236 |
| | ompt_sync_region_barrier_implicit_workshare | SR_BARRIER_IMPL_WORKSHARE | |
| 237 |
| | ompt_sync_region_barrier_implicit_parallel | SR_BARRIER_IMPL_PARALLEL | |
| 238 |
| | ompt_sync_region_barrier_teams | SR_BARRIER_TEAMS | |
| 239 |
|
| 240 |
|
| 241 |
Limitations |
| 242 |
=========== |
| 243 |
Currently, there are some peculiarities which have to be kept in mind when using |
| 244 |
this library: |
| 245 |
|
| 246 |
## Callbacks |
| 247 |
* It is not possible to e.g. test non-EMI -AND- EMI callbacks within the same |
| 248 |
test file. Reason: all testsuites share the initialization and therefore the |
| 249 |
registered callbacks. |
| 250 |
* It is not possible to check for device initialization and/or load callbacks |
| 251 |
more than once per test file. The first testcase being run, triggers these |
| 252 |
callbacks and is therefore the only testcase that is able to check for them. |
| 253 |
This is because, after that, the device remains initialized. |
| 254 |
* It is not possible to check for device finalization callbacks, as libomptest |
| 255 |
is un-loaded before this callback occurs. Same holds true for the final |
| 256 |
ThreadEnd event(s). |
| 257 |
|
| 258 |
Miscellaneous |
| 259 |
============= |
| 260 |
|
| 261 |
## Default values |
| 262 |
|
| 263 |
To allow for easier writing of tests, many OMPT events may be created using less |
| 264 |
parameters than actually requested by the spec -- by using default values. These |
| 265 |
defaults are currently set to the corresponding data type's minimum as follows, |
| 266 |
for example integers use: `std::numeric_limits<int>::min()`. |
| 267 |
|
| 268 |
When an expected / user-specified event has certain values set to the |
| 269 |
corresponding default, these values are ignored. That is, when compared to an |
| 270 |
observed event, this property is considered as 'equal' regardless of their |
| 271 |
actual equality relation. |
| 272 |
|
| 273 |
References |
| 274 |
========== |
| 275 |
[0]: ompTest – Unit Testing with OMPT |
| 276 |
https://doi.org/10.1109/SCW63240.2024.00031 |
| 277 |
|
| 278 |
[1]: OMPTBench – OpenMP Tool Interface Conformance Testing |
| 279 |
https://doi.org/10.1109/SCW63240.2024.00036 |