Skip to content

Commit 308cb7a

Browse files
committed
binding framework: add a TS_LEVEL type
Signed-off-by: Howard Pritchard <[email protected]>
1 parent f7ae46d commit 308cb7a

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

ompi/mpi/bindings/ompi_bindings/c_type.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,50 @@ def type_text(self, enable_count=False):
11111111
type_name = self.mangle_name('MPI_Message')
11121112
return f'{type_name} *'
11131113

1114+
@Type.add_type('TS_LEVEL', abi_type=['ompi'])
1115+
class TypeTSLevel(Type):
1116+
1117+
def type_text(self, enable_count=False):
1118+
return 'int'
1119+
1120+
1121+
@Type.add_type('TS_LEVEL', abi_type=['standard'])
1122+
class TypeTSLevelStandard(StandardABIType):
1123+
1124+
@property
1125+
def init_code(self):
1126+
return [f'int {self.tmpname} = {ConvertFuncs.TS_LEVEL}({self.name});']
1127+
1128+
def tmp_type_text(self, enable_count=False):
1129+
return 'int'
1130+
1131+
def return_code(self, name):
1132+
return [f'return {ConvertOMPIToStandard.TS_LEVEL}({name});']
1133+
1134+
def type_text(self, enable_count=False):
1135+
return 'int'
1136+
1137+
1138+
@Type.add_type('TS_LEVEL_OUT', abi_type=['ompi'])
1139+
class TypeTSLevelOut(Type):
1140+
1141+
def type_text(self, enable_count=False):
1142+
return 'int *'
1143+
1144+
1145+
@Type.add_type('TS_LEVEL_OUT', abi_type=['standard'])
1146+
class TypeTSLevelOutStandard(StandardABIType):
1147+
1148+
@property
1149+
def final_code(self):
1150+
return [f'*{self.name} = {ConvertOMPIToStandard.TS_LEVEL}((int) *{self.name});']
1151+
1152+
def type_text(self, enable_count=False):
1153+
return f'int *'
1154+
1155+
@property
1156+
def argument(self):
1157+
return f'{self.name}'
11141158

11151159
@Type.add_type('COMM_ERRHANDLER_FUNCTION', abi_type=['ompi'])
11161160
class TypeCommErrhandlerFunction(Type):

ompi/mpi/bindings/ompi_bindings/consts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class ConvertFuncs:
275275
WIN = 'ompi_convert_abi_win_intern_win'
276276
INFO = 'ompi_convert_abi_info_intern_info'
277277
FILE = 'ompi_convert_abi_file_intern_file'
278+
TS_LEVEL = 'ompi_convert_abi_ts_level_intern_ts_level'
278279

279280

280281
class ConvertOMPIToStandard:
@@ -293,6 +294,7 @@ class ConvertOMPIToStandard:
293294
WIN = 'ompi_convert_win_ompi_to_standard'
294295
REQUEST = 'ompi_convert_ompi_request_abi_request'
295296
INFO = 'ompi_convert_info_ompi_to_standard'
297+
TS_LEVEL = 'ompi_convert_ts_level_ompi_to_standard'
296298

297299

298300
# Inline function attributes

ompi/mpi/c/abi_converters.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,34 @@ __opal_attribute_always_inline__ static inline void ompi_convert_intern_status_a
561561
memcpy(ptr, &inp->_ucount,sizeof(inp->_ucount));
562562
}
563563

564+
__opal_attribute_always_inline__ static inline int ompi_convert_abi_ts_level_intern_ts_level(int ts_level)
565+
{
566+
if (MPI_THREAD_SINGLE_ABI_INTERNAL == ts_level) {
567+
return MPI_THREAD_SINGLE;
568+
} else if (MPI_THREAD_FUNNELED_ABI_INTERNAL == ts_level) {
569+
return MPI_THREAD_FUNNELED;
570+
} else if (MPI_THREAD_SERIALIZED_ABI_INTERNAL == ts_level) {
571+
return MPI_THREAD_SERIALIZED;
572+
} else if (MPI_THREAD_MULTIPLE_ABI_INTERNAL == ts_level) {
573+
return MPI_THREAD_MULTIPLE;
574+
}
575+
return ts_level;
576+
}
577+
578+
__opal_attribute_always_inline__ static inline int ompi_convert_ts_level_ompi_to_standard(int ts_level)
579+
{
580+
if (MPI_THREAD_SINGLE == ts_level) {
581+
return MPI_THREAD_SINGLE_ABI_INTERNAL;
582+
} else if (MPI_THREAD_FUNNELED == ts_level) {
583+
return MPI_THREAD_FUNNELED_ABI_INTERNAL;
584+
} else if (MPI_THREAD_SERIALIZED == ts_level) {
585+
return MPI_THREAD_SERIALIZED_ABI_INTERNAL;
586+
} else if (MPI_THREAD_MULTIPLE == ts_level) {
587+
return MPI_THREAD_MULTIPLE_ABI_INTERNAL;
588+
}
589+
return ts_level;
590+
}
591+
564592
#if defined(c_plusplus) || defined(__cplusplus)
565593
}
566594
#endif

ompi/mpi/c/init_thread.c.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#include "ompi/constants.h"
3838
#include "ompi/mca/hook/base/base.h"
3939

40-
PROTOTYPE ERROR_CLASS init_thread(INT_OUT argc, ARGV argv, INT required,
41-
INT_OUT provided)
40+
PROTOTYPE ERROR_CLASS init_thread(INT_OUT argc, ARGV argv, TS_LEVEL required,
41+
TS_LEVEL_OUT provided)
4242
{
4343
int err, safe_required = MPI_THREAD_SERIALIZED;
4444
bool err_arg_required = false;

0 commit comments

Comments
 (0)