1
- from ccharm cimport *
1
+ # cython: language_level=3
2
+
3
+ from charm4py.charmlib.ccharm cimport *
2
4
from libc.stdlib cimport malloc, free
3
5
from libc.string cimport memcpy
4
6
from libc.stdint cimport uintptr_t
@@ -222,8 +224,7 @@ cdef class ReceiveMsgBuffer:
222
224
self .msg = NULL
223
225
224
226
cdef inline int isLocal(self ):
225
- return self .msg[0 ] == ' L' and self .msg[1 ] == ' :'
226
-
227
+ return self .msg[0 ] == b' L' and self .msg[1 ] == b' :'
227
228
cdef inline int getLocalTag(self ):
228
229
return (< int * > (& self .msg[2 ]))[0 ]
229
230
@@ -827,27 +828,27 @@ class CharmLib(object):
827
828
828
829
829
830
# first callback from Charm++ shared library
830
- cdef void registerMainModule():
831
+ cdef void registerMainModule() noexcept :
831
832
try :
832
833
charm.registerMainModule()
833
834
except :
834
835
charm.handleGeneralError()
835
836
836
- cdef void recvReadOnly(int msgSize, char * msg):
837
+ cdef void recvReadOnly(int msgSize, char * msg) noexcept :
837
838
try :
838
839
recv_buffer.setMsg(msg, msgSize)
839
840
charm.recvReadOnly(recv_buffer)
840
841
except :
841
842
charm.handleGeneralError()
842
843
843
- cdef void buildMainchare(int onPe, void * objPtr, int ep, int argc, char ** argv):
844
+ cdef void buildMainchare(int onPe, void * objPtr, int ep, int argc, char ** argv) noexcept :
844
845
try :
845
846
args = [argv[i].decode(' UTF-8' ) for i in range (argc)]
846
847
charm.buildMainchare(onPe, < uintptr_t> objPtr, ep, args)
847
848
except :
848
849
charm.handleGeneralError()
849
850
850
- cdef void recvChareMsg(int onPe, void * objPtr, int ep, int msgSize, char * msg, int dcopy_start):
851
+ cdef void recvChareMsg(int onPe, void * objPtr, int ep, int msgSize, char * msg, int dcopy_start) noexcept :
851
852
try :
852
853
if PROFILING:
853
854
charm._precvtime = time.time()
@@ -857,7 +858,7 @@ cdef void recvChareMsg(int onPe, void *objPtr, int ep, int msgSize, char *msg, i
857
858
except :
858
859
charm.handleGeneralError()
859
860
860
- cdef void recvGroupMsg(int gid, int ep, int msgSize, char * msg, int dcopy_start):
861
+ cdef void recvGroupMsg(int gid, int ep, int msgSize, char * msg, int dcopy_start) noexcept :
861
862
try :
862
863
if PROFILING:
863
864
charm._precvtime = time.time()
@@ -867,7 +868,7 @@ cdef void recvGroupMsg(int gid, int ep, int msgSize, char *msg, int dcopy_start)
867
868
except :
868
869
charm.handleGeneralError()
869
870
870
- cdef void recvArrayMsg(int aid, int ndims, int * arrayIndex, int ep, int msgSize, char * msg, int dcopy_start):
871
+ cdef void recvArrayMsg(int aid, int ndims, int * arrayIndex, int ep, int msgSize, char * msg, int dcopy_start) noexcept :
871
872
try :
872
873
if PROFILING:
873
874
charm._precvtime = time.time()
@@ -877,7 +878,7 @@ cdef void recvArrayMsg(int aid, int ndims, int *arrayIndex, int ep, int msgSize,
877
878
except :
878
879
charm.handleGeneralError()
879
880
880
- cdef void recvArrayBcast(int aid, int ndims, int nInts, int numElems, int * arrayIndexes, int ep, int msgSize, char * msg, int dcopy_start):
881
+ cdef void recvArrayBcast(int aid, int ndims, int nInts, int numElems, int * arrayIndexes, int ep, int msgSize, char * msg, int dcopy_start) noexcept :
881
882
cdef int i = 0
882
883
try :
883
884
if PROFILING:
@@ -892,13 +893,13 @@ cdef void recvArrayBcast(int aid, int ndims, int nInts, int numElems, int *array
892
893
except :
893
894
charm.handleGeneralError()
894
895
895
- cdef int arrayMapProcNum(int gid, int ndims, const int * arrayIndex):
896
+ cdef int arrayMapProcNum(int gid, int ndims, const int * arrayIndex) noexcept :
896
897
try :
897
898
return charm.arrayMapProcNum(gid, array_index_to_tuple(ndims, arrayIndex))
898
899
except :
899
900
charm.handleGeneralError()
900
901
901
- cdef int arrayElemLeave(int aid, int ndims, int * arrayIndex, char ** pdata, int sizing):
902
+ cdef int arrayElemLeave(int aid, int ndims, int * arrayIndex, char ** pdata, int sizing) noexcept :
902
903
cdef int i = 0
903
904
global tempData
904
905
try :
@@ -914,7 +915,7 @@ cdef int arrayElemLeave(int aid, int ndims, int *arrayIndex, char **pdata, int s
914
915
except :
915
916
charm.handleGeneralError()
916
917
917
- cdef void arrayElemJoin(int aid, int ndims, int * arrayIndex, int ep, char * msg, int msgSize):
918
+ cdef void arrayElemJoin(int aid, int ndims, int * arrayIndex, int ep, char * msg, int msgSize) noexcept :
918
919
cdef int i = 0
919
920
try :
920
921
if PROFILING:
@@ -925,7 +926,7 @@ cdef void arrayElemJoin(int aid, int ndims, int *arrayIndex, int ep, char *msg,
925
926
except :
926
927
charm.handleGeneralError()
927
928
928
- cdef void resumeFromSync(int aid, int ndims, int * arrayIndex):
929
+ cdef void resumeFromSync(int aid, int ndims, int * arrayIndex) noexcept :
929
930
cdef int i = 0
930
931
try :
931
932
index = array_index_to_tuple(ndims, arrayIndex)
@@ -935,7 +936,7 @@ cdef void resumeFromSync(int aid, int ndims, int *arrayIndex):
935
936
charm.handleGeneralError()
936
937
937
938
cdef void createCallbackMsg(void * data, int dataSize, int reducerType, int fid, int * sectionInfo,
938
- char ** returnBuffers, int * returnBufferSizes):
939
+ char ** returnBuffers, int * returnBufferSizes) noexcept :
939
940
cdef int numElems
940
941
cdef array.array a
941
942
cdef int item_size
@@ -969,7 +970,7 @@ cdef void createCallbackMsg(void *data, int dataSize, int reducerType, int fid,
969
970
header = {}
970
971
ctype = charm_reducer_to_ctype[reducerType]
971
972
item_size = c_type_table_sizes[ctype]
972
- numElems = dataSize / item_size
973
+ numElems = dataSize // item_size # force integer division for cython + python3
973
974
if fid > 0 :
974
975
pyData.append(fid)
975
976
if numElems == 1 :
@@ -1021,7 +1022,7 @@ cdef void createCallbackMsg(void *data, int dataSize, int reducerType, int fid,
1021
1022
charm.handleGeneralError()
1022
1023
1023
1024
# callback function invoked by Charm++ for reducing contributions using a Python reducer (built-in or custom)
1024
- cdef int pyReduction(char ** msgs, int * msgSizes, int nMsgs, char ** returnBuffer):
1025
+ cdef int pyReduction(char ** msgs, int * msgSizes, int nMsgs, char ** returnBuffer) noexcept :
1025
1026
cdef int i = 0
1026
1027
cdef int msgSize
1027
1028
global tempData
@@ -1054,7 +1055,7 @@ cdef int pyReduction(char** msgs, int* msgSizes, int nMsgs, char** returnBuffer)
1054
1055
except :
1055
1056
charm.handleGeneralError()
1056
1057
1057
- cdef void CcdCallFnAfterCallback(void * userParam, double curWallTime):
1058
+ cdef void CcdCallFnAfterCallback(void * userParam, double curWallTime) noexcept :
1058
1059
try :
1059
1060
charm.triggerCallable(< int > userParam)
1060
1061
except :
0 commit comments