Skip to content

Projections support #290

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

Open
wants to merge 69 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
3f6da24
add pairwise addition/product
ZwFink Oct 9, 2020
3ed6ce5
add logical reductions
ZwFink Oct 9, 2020
a180dca
add tests for section-based reductions
ZwFink Oct 12, 2020
16d1d34
wip
ZwFink Oct 15, 2020
4ef355a
reductions are now optimized for numpy types
ZwFink Oct 16, 2020
48e86ec
numpy reductions always preferred when available
ZwFink Oct 19, 2020
ba0679d
added checks that single-value reductions work with sections
ZwFink Oct 19, 2020
4ad6af4
add section reduction test
ZwFink Oct 19, 2020
5479d56
no fstrings allowed
ZwFink Oct 19, 2020
10175f0
remove unused time import
ZwFink Oct 19, 2020
d01efd9
scookies -> _scookies
ZwFink Oct 19, 2020
fd04ae6
add check so overflowing number of futures is not silent
ZwFink Oct 19, 2020
e207b36
cleanup
ZwFink Oct 20, 2020
5531c5c
remove unused operator import
ZwFink Oct 20, 2020
2e1b59c
use newest import
ZwFink Oct 20, 2020
12a9f3b
operator import is actually required
ZwFink Oct 20, 2020
16a79a1
make new code flake8 compliant
ZwFink Oct 27, 2020
a3165e2
update
ZwFink Nov 12, 2020
83ba3bb
add EP name registration
ZwFink Nov 21, 2020
4518ff8
projections support for groups
ZwFink Nov 24, 2020
1d8d216
added CkRegisterMainChare to list of methods that are now correctly t…
ZwFink Dec 2, 2020
6359e1c
section entry methods are now traced
ZwFink Dec 3, 2020
577a1bd
added registration to ArrayMaps
ZwFink Dec 17, 2020
8124479
add registration support for ArrayMap
ZwFink Dec 17, 2020
0a22731
Add data required for projections to registration
ZwFink Dec 18, 2020
689ad4f
Removed global entryNames/entryNamesLen. Unnecessary 'emStart'
ZwFink Dec 18, 2020
d476e91
Moved entry method name tracking inside charmlib
ZwFink Dec 18, 2020
387bc2b
Do we want to free the memory?
ZwFink Dec 23, 2020
122cb18
Add '--enable-tracing' option to setup.py
ZwFink Dec 28, 2020
5c2df8d
Checkout the charm4py_projections branch for running tests
ZwFink Dec 28, 2020
55159b9
Temporarily disable the ctypes interface in testing
ZwFink Dec 28, 2020
15eb21f
Merge branch 'master' into projections_support
ZwFink Dec 28, 2020
6cb55e0
fix conflicts
ZwFink Oct 14, 2021
4f65ec6
Add tracing of user events
ZwFink Oct 14, 2021
1f1c054
Add object store implementation
adityapb Oct 7, 2023
025ac7c
Buffer task until object is available
adityapb Oct 9, 2023
72e68a9
Fix buffering messages on target PE
adityapb Oct 10, 2023
b68242c
Fix segmentation fault with object store
adityapb Nov 6, 2023
82760de
Add some documentation for the object store
adityapb Nov 6, 2023
82eb577
Implemented waiting for futures
adityapb Nov 6, 2023
4b2557f
Add parameter server training example
adityapb Nov 6, 2023
76523f5
Add requested flag to futures to avoid multiple requests for the same…
adityapb Nov 6, 2023
077eaae
Add ray.wait function
adityapb Nov 7, 2023
64575f9
Add async parameter server
adityapb Nov 7, 2023
795593d
Implement ray.put function to insert object in the object store
adityapb Nov 7, 2023
01fbe0e
Merge ray futures and charm futures
adityapb Jan 15, 2024
e1a03df
Add store option to futures
adityapb Jan 15, 2024
c66d28f
Check future arguments in group methods
adityapb Jan 29, 2024
b4867a3
Try ray tasks implementation using charm4py pool
adityapb Jan 29, 2024
e1ed79b
pool example
Jan 29, 2024
f8194ac
Merge branch 'ray' of https://github.com/UIUC-PPL/charm4py into ray
Jan 29, 2024
ac0521b
Remove checking for futures from groups
adityapb Jan 29, 2024
fdd96e0
Stateless tasks and exit calls work
adityapb Jan 29, 2024
ec06b23
Working stateless tasks implementation
adityapb Feb 5, 2024
fb235bc
Add more examples
adityapb Feb 26, 2024
c0bf94c
Fix ray.get calls from remote functions
adityapb Feb 28, 2024
d0b8ab3
Add fib example to debug MPI issue
adityapb Mar 1, 2024
c5bbbc5
For small objects, store them at home
adityapb Mar 5, 2024
a971227
Merge branch 'main' into ray
Mar 6, 2024
44acea4
merge ray into projections support
Mar 18, 2024
f2ac82b
Revert "merge ray into projections support"
Mar 18, 2024
4fe8088
update projections branch
ritvikrao Mar 17, 2025
498c1d3
Merge branch 'main' into projections_support
ritvikrao Mar 17, 2025
9723c19
remove generated files
ritvikrao Mar 17, 2025
eb79fef
merge fixes
ritvikrao Mar 17, 2025
fbaf03a
merge fixes 2
ritvikrao Mar 17, 2025
e2e59c3
merge fixes 3
ritvikrao Mar 17, 2025
e83e029
add back entry names to libRegisterFunc:
ritvikrao Mar 17, 2025
a93f6b1
merge
ritvikrao Apr 22, 2025
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
5 changes: 2 additions & 3 deletions charm4py/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,8 @@ def packMsg(self, destObj, msgArgs, header):
def registerInCharmAs(self, C, charm_type, libRegisterFunc):
charm_type_id = charm_type.type_id
entryMethods = self.classEntryMethods[charm_type_id][C]
# if self.myPe() == 0: print("charm4py:: Registering class " + C.__name__ + " in Charm with " + str(len(entryMethods)) + " entry methods " + str([e.name for e in entryMethods]))
C.idx[charm_type_id], startEpIdx = libRegisterFunc(C.__name__ + str(charm_type_id), len(entryMethods))
# if self.myPe() == 0: print("charm4py:: Chare idx=" + str(C.idx[charm_type_id]) + " ctor Idx=" + str(startEpIdx))
entryNames = [method.name for method in entryMethods]
C.idx[charm_type_id], startEpIdx = libRegisterFunc(C.__name__ + str(charm_type_id), entryNames, len(entryMethods))
for i, em in enumerate(entryMethods):
em.epIdx = startEpIdx + i
self.entryMethods[em.epIdx] = em
Expand Down
14 changes: 9 additions & 5 deletions charm4py/charmlib/ccharm.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ cdef extern from "charm.h":
int CmiPhysicalRank(int pe);

void CkRegisterReadonlyExt(const char *name, const char *type, size_t msgSize, char *msg);
void CkRegisterMainChareExt(const char *s, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterGroupExt(const char *s, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterSectionManagerExt(const char *s, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterArrayExt(const char *s, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterArrayMapExt(const char *s, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterMainChareExt(const char *s, const char **emNames, int emNamesStart, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterGroupExt(const char *s, const char **emNames, int emNamesStart, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterSectionManagerExt(const char *s, const char **emNames, int emNamesStart, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterArrayExt(const char *s, const char **emNames, int emNamesStart, int numEntryMethods, int *chareIdx, int *startEpIdx);
void CkRegisterArrayMapExt(const char *s, const char **emNames, int emNamesStart, int numEntryMethods, int *chareIdx, int *startEpIdx);

int CkCreateGroupExt(int cIdx, int eIdx, int num_bufs, char **bufs, int *buf_sizes);
int CkCreateArrayExt(int cIdx, int ndims, int *dims, int eIdx, int num_bufs, char **bufs, int *buf_sizes, int map_gid, char useAtSync);
Expand Down Expand Up @@ -70,6 +70,10 @@ cdef extern from "charm.h":
void CkStartQDExt_SectionCallback(int sid_pe, int sid_cnt, int rootPE, int ep);
void CcdCallFnAfter(void (*CcdVoidFn)(void *userParam,double curWallTime), void *arg, double msecs);

int CkTraceRegisterUserEvent(char *EventDesc, int eventID);
void CkTraceBeginUserBracketEvent(int eventID);
void CkTraceEndUserBracketEvent(int eventID);

cdef extern from "conv-header.h":
ctypedef void (*CmiHandler)(void* )
cdef const int CmiReservedHeaderSize
Expand Down
69 changes: 59 additions & 10 deletions charm4py/charmlib/charmlib_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ from cpython.ref cimport Py_INCREF
from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
from cython.operator cimport dereference

cdef extern from "Python.h":
char* PyUnicode_AsUTF8(object unicode)

from libc.string cimport strcmp

from ..charm import Charm4PyError
from .. import reduction as red
from cpython cimport array
Expand Down Expand Up @@ -108,6 +113,17 @@ ctypedef struct CkReductionTypesExt:

cdef extern CkReductionTypesExt charm_reducers

cdef char ** to_cstring_array(list_str):
cdef char **ret = <char **>malloc(len(list_str) * sizeof(char *))
for i in range(len(list_str)):
ret[i] = list_str[i]
return ret

def addStringsToList(targetList, strings):
for idx, currentString in enumerate(strings):
targetList.append(<char*> malloc(len(currentString)))
targetList[idx] = strings[idx]

class CkReductionTypesExt_Wrapper:

def __init__(self):
Expand Down Expand Up @@ -347,6 +363,8 @@ class CharmLib(object):
self.direct_copy_supported = (PY_MAJOR_VERSION >= 3)
self.name = 'cython'
self.chareNames = []
self.emNames = []
self.emStart = 0
self.init()
self.ReducerType = CkReductionTypesExt_Wrapper()
#print(charm_reducers.sum_long, charm_reducers.product_ushort, charm_reducers.max_char, charm_reducers.max_float, charm_reducers.min_char)
Expand Down Expand Up @@ -503,34 +521,51 @@ class CharmLib(object):
if msg is None: CkRegisterReadonlyExt(n1, n2, 0, NULL)
else: CkRegisterReadonlyExt(n1, n2, len(msg), msg)

def CkRegisterMainchare(self, str name, int numEntryMethods):
def CkRegisterMainchare(self, str name, list entryMethodNames, int numEntryMethods):
self.chareNames.append(name.encode())
cdef int chareIdx, startEpIdx
CkRegisterMainChareExt(self.chareNames[-1], numEntryMethods, &chareIdx, &startEpIdx)
self.emNames += [name.encode() for name in entryMethodNames]
# TODO: do we want to track/free these pointers?
cdef char** c1 = to_cstring_array(self.emNames)
CkRegisterMainChareExt(self.chareNames[-1], c1, self.emStart, numEntryMethods, &chareIdx, &startEpIdx)
self.emStart = len(self.emNames)
return chareIdx, startEpIdx

def CkRegisterGroup(self, str name, int numEntryMethods):
def CkRegisterGroup(self, str name, list entryMethodNames, int numEntryMethods):
self.chareNames.append(name.encode())
cdef int chareIdx, startEpIdx
CkRegisterGroupExt(self.chareNames[-1], numEntryMethods, &chareIdx, &startEpIdx)
self.emNames += [name.encode() for name in entryMethodNames]
cdef char** c1 = to_cstring_array(self.emNames)
CkRegisterGroupExt(self.chareNames[-1], c1, self.emStart, numEntryMethods, &chareIdx, &startEpIdx)
self.emStart = len(self.emNames)
return chareIdx, startEpIdx

def CkRegisterSectionManager(self, str name, int numEntryMethods):
def CkRegisterSectionManager(self, str name, list entryMethodNames, int numEntryMethods):
self.chareNames.append(name.encode())
cdef int chareIdx, startEpIdx
CkRegisterSectionManagerExt(self.chareNames[-1], numEntryMethods, &chareIdx, &startEpIdx)
self.emNames += [name.encode() for name in entryMethodNames]
cdef char** c1 = to_cstring_array(self.emNames)

CkRegisterSectionManagerExt(self.chareNames[-1], c1, self.emStart, numEntryMethods, &chareIdx, &startEpIdx)
self.emStart = len(self.emNames)
return chareIdx, startEpIdx

def CkRegisterArrayMap(self, str name, int numEntryMethods):
def CkRegisterArrayMap(self, str name, list entryMethodNames, int numEntryMethods):
self.chareNames.append(name.encode())
cdef int chareIdx, startEpIdx
CkRegisterArrayMapExt(self.chareNames[-1], numEntryMethods, &chareIdx, &startEpIdx)
self.emNames += [name.encode() for name in entryMethodNames]
cdef char** c1 = to_cstring_array(self.emNames)
CkRegisterArrayMapExt(self.chareNames[-1], c1, self.emStart, numEntryMethods, &chareIdx, &startEpIdx)
self.emStart = len(self.emNames)
return chareIdx, startEpIdx

def CkRegisterArray(self, str name, int numEntryMethods):
def CkRegisterArray(self, str name, list entryMethodNames, int numEntryMethods):
self.chareNames.append(name.encode())
cdef int chareIdx, startEpIdx
CkRegisterArrayExt(self.chareNames[-1], numEntryMethods, &chareIdx, &startEpIdx)
self.emNames += [name.encode() for name in entryMethodNames]
cdef char** c1 = to_cstring_array(self.emNames)
CkRegisterArrayExt(self.chareNames[-1], c1, self.emStart, numEntryMethods, &chareIdx, &startEpIdx)
self.emStart = len(self.emNames)
return chareIdx, startEpIdx

def CkCreateGroup(self, int chareIdx, int epIdx, msg not None):
Expand Down Expand Up @@ -852,6 +887,20 @@ class CharmLib(object):
def scheduleTagAfter(self, int tag, double msecs):
CcdCallFnAfter(CcdCallFnAfterCallback, <void*>tag, msecs)

def traceRegisterUserEvent(self, str EventDesc, int eventNum=-1):
cdef bytes py_bytes = EventDesc.encode()
Py_INCREF(py_bytes)
# This memory needs to be managed somehow, I think
cdef char* c_string = py_bytes
cdef int eventID = CkTraceRegisterUserEvent(c_string, eventNum)
return eventID

def traceBeginUserBracketEvent(self, int EventID):
CkTraceBeginUserBracketEvent(EventID)

def traceEndUserBracketEvent(self, int EventID):
CkTraceEndUserBracketEvent(EventID)

def CcsRegisterHandler(self, str handlername, object handler):
cdef bytes handler_bytes = handlername.encode("utf-8")
cdef const char* c_handlername = handler_bytes
Expand Down
2 changes: 1 addition & 1 deletion charm4py/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def is_tag_cond(root_ast):
idx = idx.n
elif isinstance(idx, ast.Constant):
idx = idx.value

if not isinstance(idx, int):
return None

Expand Down
2 changes: 1 addition & 1 deletion examples/hello/group_hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def main(args):
group_proxy[0].sayHi(17)


charm.start(main)
charm.start(main)
28 changes: 24 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Cython.Compiler.Options.annotate = True

build_mpi = False

enable_tracing = False


def get_build_machine():
Expand Down Expand Up @@ -149,6 +149,9 @@ def build_libcharm(charm_src_dir, build_dir):
build_num_cores = max(int(os.environ.get('CHARM_BUILD_PROCESSES', multiprocessing.cpu_count() // 2)), 1)
extra_build_opts = os.environ.get('CHARM_EXTRA_BUILD_OPTS', '')

if enable_tracing:
extra_build_opts += " --enable-tracing "

target_machine, os_target, target_layer = get_build_triple(build_mpi)

build_triple = f'{target_layer}-{os_target}-{target_machine}'
Expand Down Expand Up @@ -198,17 +201,23 @@ def build_libcharm(charm_src_dir, build_dir):
class custom_install(install, object):

user_options = install.user_options + [
('mpi', None, 'Build libcharm with MPI')
('mpi', None, 'Build libcharm with MPI'),
('enable-tracing', None, 'Build libcharm with tracing enabled')
]

def initialize_options(self):
install.initialize_options(self)
self.mpi = False
self.enable_tracing = False

def finalize_options(self):
global build_mpi
if not build_mpi:
build_mpi = bool(self.mpi)

global enable_tracing
if not enable_tracing:
enable_tracing = bool(self.enable_tracing)
install.finalize_options(self)

def run(self):
Expand All @@ -218,17 +227,22 @@ def run(self):
class custom_build_py(build_py, object):

user_options = build_py.user_options + [
('mpi', None, 'Build libcharm with MPI')
('mpi', None, 'Build libcharm with MPI'),
('enable-tracing', None, 'Build libcharm with tracing enabled')
]

def initialize_options(self):
build_py.initialize_options(self)
self.mpi = False
self.enable_tracing = False

def finalize_options(self):
global build_mpi
if not build_mpi:
build_mpi = bool(self.mpi)
global enable_tracing
if not enable_tracing:
enable_tracing = bool(self.enable_tracing)
build_py.finalize_options(self)

def run(self):
Expand All @@ -241,17 +255,23 @@ def run(self):
class custom_build_ext(build_ext, object):

user_options = build_ext.user_options + [
('mpi', None, 'Build libcharm with MPI')
('mpi', None, 'Build libcharm with MPI'),
('enable-tracing', None, 'Build libcharm with tracing enabled')
]

def initialize_options(self):
build_ext.initialize_options(self)
self.mpi = False
self.enable_tracing = False

def finalize_options(self):
global build_mpi
if not build_mpi:
build_mpi = bool(self.mpi)

global enable_tracing
if not enable_tracing:
enable_tracing = bool(self.enable_tracing)
build_ext.finalize_options(self)

def run(self):
Expand Down
Loading