-
Notifications
You must be signed in to change notification settings - Fork 1
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
cffi: typedef shmem_{ctx|team}_t as an opaque struct type #24
Open
dalcinl
wants to merge
1
commit into
master
Choose a base branch
from
refactor/ctx-team
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This allows for OpenSHMEM implementations declaring ctx/team types as either a pointer types or an integral types. Declaring `shmem_{ctx|team}_t` as an opaque struct type has an annoying side-effect: now ctx/team handles can no longer be compared for equality. Therefore, add a couple auxiliary functions `eq_{ctx|team}` to compare handles for equality. Additionally, in case we need them in the future, add functions to convert to/from integer values.
@jeffhammond I managed to find a way to address our Cray issue, albeit at the expense of slightly uglier implementation code in the Python side. |
This is what worked on LUMI: diff --git a/src/apicodegen.py b/src/apicodegen.py
index e6acec0..d0ece31 100644
--- a/src/apicodegen.py
+++ b/src/apicodegen.py
@@ -23,8 +23,8 @@ typename_to_type = {
'float': 'float',
'double': 'double',
'longdouble': 'long double',
- 'complexf': 'float _Complex',
- 'complexd': 'double _Complex',
+ #'complexf': 'float _Complex',
+ #'complexd': 'double _Complex',
}
typesizes_rma = (
@@ -122,8 +122,8 @@ typenames_reduce = {
'float': " max min sum prod".split(),
'double': " max min sum prod".split(),
'longdouble': " max min sum prod".split(),
- 'complexd': " sum prod".split(),
- 'complexf': " sum prod".split(),
+ #'complexd': " sum prod".split(),
+ #'complexf': " sum prod".split(),
}
@@ -213,7 +213,7 @@ int shmem_alltoallsmem(shmem_team_t team, void *dest, const void *source, ptrdif
reduce_ops = ('and', 'or', 'xor', 'max', 'min', 'sum', 'prod')
reduce_team = """
-int shmem_{TYPENAME}_{OP}_reduce(shmem_team_t team, {TYPE} *dest, const {TYPE} *source, size_t nreduce);
+void shmem_{TYPENAME}_{OP}_reduce(shmem_team_t team, {TYPE} *dest, const {TYPE} *source, size_t nreduce);
""" # noqa
wait = """
diff --git a/src/libshmem/config/cray.h b/src/libshmem/config/cray.h
index db66c31..01ed740 100644
--- a/src/libshmem/config/cray.h
+++ b/src/libshmem/config/cray.h
@@ -1,4 +1,27 @@
#ifndef PySHMEM_CONFIG_CRAY_H
#define PySHMEM_CONFIG_CRAY_H
+#if CRAY_SHMEM_MAJOR_VERSION >= 11
+#define PySHMEM_HAVE_shmem_malloc_with_hints 1
+#define PySHMEM_HAVE_shmem_team_t 1
+#define PySHMEM_HAVE_SHMEM_CTX_INVALID 1
+#define PySHMEM_HAVE_shmem_amo_nbi 1
+#define PySHMEM_HAVE_shmem_put_signal 1
+#define PySHMEM_HAVE_shmem_signal_fetch 1
+#define PySHMEM_HAVE_shmem_signal_wait_until 1
+#define PySHMEM_HAVE_shmem_broadcast 1
+#define PySHMEM_HAVE_shmem_collect 1
+#define PySHMEM_HAVE_shmem_fcollect 1
+#define PySHMEM_HAVE_shmem_alltoall 1
+#define PySHMEM_HAVE_shmem_alltoalls 1
+#define PySHMEM_HAVE_shmem_broadcastmem 1
+#define PySHMEM_HAVE_shmem_collectmem 1
+#define PySHMEM_HAVE_shmem_fcollectmem 1
+#define PySHMEM_HAVE_shmem_alltoallmem 1
+#define PySHMEM_HAVE_shmem_alltoallsmem 1
+#define PySHMEM_HAVE_shmem_reduce 1
+#define PySHMEM_HAVE_shmem_wait_test_many 1
+//#define PySHMEM_HAVE_shmem_pcontrol 1
+#endif
+
#endif
diff --git a/src/libshmem/fallback.h b/src/libshmem/fallback.h
index 808fd74..f291abd 100644
--- a/src/libshmem/fallback.h
+++ b/src/libshmem/fallback.h
@@ -658,8 +658,8 @@ PySHMEM_REDUCE_2(longlong, long long)
PySHMEM_REDUCE_2(float, float)
PySHMEM_REDUCE_2(double, double)
PySHMEM_REDUCE_2(longdouble, long double)
-PySHMEM_REDUCE_1(complexf, float _Complex)
-PySHMEM_REDUCE_1(complexd, double _Complex)
+//PySHMEM_REDUCE_1(complexf, float _Complex)
+//PySHMEM_REDUCE_1(complexd, double _Complex)
#define PySHMEM_REDUCE_UINT_OP(TYPENAME, TYPE, OP) \
static \
diff --git a/src/shmem4py/shmem.py b/src/shmem4py/shmem.py
index 67087c9..756d058 100644
--- a/src/shmem4py/shmem.py
+++ b/src/shmem4py/shmem.py
@@ -2263,7 +2263,7 @@ def reduce(
team_ = team.ob_team if team is not None else lib.SHMEM_TEAM_WORLD
ctype, target, source, size = _parse_reduce(target, source, size)
shmem_reduce = _shmem(None, ctype, f'{op}_reduce')
- ierr = shmem_reduce(team_, target, source, size)
+ ierr = shmem_reduce(team_, target, source, size) or 0
_chkerr(ierr, f"shmem_{ctype}_{op}_reduce")
|
the complex stuff is a hack. i haven't tried to fix it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows for OpenSHMEM implementations declaring ctx/team types as either a pointer types or an integral types.
Declaring
shmem_{ctx|team}_t
as an opaque struct type has an annoying side-effect: now ctx/team handles can no longer be compared for equality. Therefore, add a couple auxiliary functionseq_{ctx|team}
to compare handles for equality. Additionally, in case we need them in the future, add functions to convert to/from integer values.