Open ronawho opened 4 months ago
Alternative approach that doesn't duplicate as much:
diff --git a/test/unit/c11_test_shmem_atomic_fetch.c b/test/unit/c11_test_shmem_atomic_fetch.c
index 3c75256..d5b5669 100644
--- a/test/unit/c11_test_shmem_atomic_fetch.c
+++ b/test/unit/c11_test_shmem_atomic_fetch.c
@@ -40,11 +40,10 @@
enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI,
CTX_ATOMIC_FETCH_NBI };
-#ifdef ENABLE_DEPRECATED_TESTS
-#define DEPRECATED_FETCH shmem_fetch
-#else
-#define DEPRECATED_FETCH shmem_atomic_fetch
-#endif
+#define SHMEM_DEPRECATED_OPS_CASES(OP, TYPE) \
+ case FETCH: \
+ val = shmem_fetch(&remote, (mype + 1) % npes); \
+ break;
#define SHMEM_NBI_OPS_CASES(OP, TYPE) \
case ATOMIC_FETCH_NBI: \
@@ -67,9 +66,7 @@ enum op { FETCH = 0, ATOMIC_FETCH, CTX_ATOMIC_FETCH, ATOMIC_FETCH_NBI,
remote = (TYPE)mype; \
shmem_barrier_all(); \
switch (OP) { \
- case FETCH: \
- val = DEPRECATED_FETCH(&remote, (mype + 1) % npes); \
- break; \
+ SHMEM_DEPRECATED_OPS_CASES(OP, TYPE) \
case ATOMIC_FETCH: \
val = shmem_atomic_fetch(&remote, (mype + 1) % npes); \
break; \
@@ -104,16 +101,9 @@ int main(int argc, char* argv[]) {
TEST_SHMEM_FETCH(FETCH, int);
TEST_SHMEM_FETCH(FETCH, long);
TEST_SHMEM_FETCH(FETCH, long long);
- TEST_SHMEM_FETCH(FETCH, unsigned int);
- TEST_SHMEM_FETCH(FETCH, unsigned long);
- TEST_SHMEM_FETCH(FETCH, unsigned long long);
- TEST_SHMEM_FETCH(FETCH, int32_t);
- TEST_SHMEM_FETCH(FETCH, int64_t);
- TEST_SHMEM_FETCH(FETCH, uint32_t);
- TEST_SHMEM_FETCH(FETCH, uint64_t);
- TEST_SHMEM_FETCH(FETCH, size_t);
- TEST_SHMEM_FETCH(FETCH, ptrdiff_t);
#endif /* ENABLE_DEPRECATED_TESTS */
+#undef SHMEM_DEPRECATED_OPS_CASES
+#define SHMEM_DEPRECATED_OPS_CASES(OP, TYPE)
TEST_SHMEM_FETCH(ATOMIC_FETCH, float);
TEST_SHMEM_FETCH(ATOMIC_FETCH, double);
Tests like c11_test_shmem_atomic_fetch.c check APIs that aren't defined in the spec. e.g. https://github.com/openshmem-org/tests-sos/blob/2d4a704cda2f3fa042c634ff91f12ab2639f770c/test/unit/c11_test_shmem_atomic_fetch.c#L107-L115
calls
shmem_fetch
on types likesize_t
, but the spec says:I'd be happy to make changes to the tests, but am not sure what the best approach is. The runtime selection of the fetch operation means even the non-deprecated tests end up with a "potential" call to the non-spec functions. Left to my own devices I might just split out the deprecated fetch into a new macro (example in details below), but wasn't sure if there's a more preferred approach.