356 #ifndef OTF2_MPI_COLLECTIVES_H
357 #define OTF2_MPI_COLLECTIVES_H
381 MPI_Comm localComm );
397 uint32_t numberOfFiles );
409 MPI_Comm globalComm );
422 #ifdef OTF2_MPI_USE_PMPI
423 # define CALL_MPI( name ) P ## name
425 # define CALL_MPI( name ) name
426 # define OTF2_MPI_USE_PMPI
427 # define OTF2_MPI_USE_PMPI_undef_me
438 #ifndef OTF2_MPI_UINT8_T
439 # if MPI_VERSION >= 3
440 # define OTF2_MPI_UINT8_T MPI_UINT8_T
442 # define OTF2_MPI_UINT8_T MPI_UNSIGNED_CHAR
453 #ifndef OTF2_MPI_INT8_T
454 # if MPI_VERSION >= 3
455 # define OTF2_MPI_INT8_T MPI_INT8_T
457 # define OTF2_MPI_INT8_T MPI_CHAR
469 #ifndef OTF2_MPI_UINT16_T
470 # if MPI_VERSION >= 3
471 # define OTF2_MPI_UINT16_T MPI_UINT16_T
473 # define OTF2_MPI_UINT16_T MPI_UNSIGNED_SHORT
484 #ifndef OTF2_MPI_INT16_T
485 # if MPI_VERSION >= 3
486 # define OTF2_MPI_INT16_T MPI_INT16_T
488 # define OTF2_MPI_INT16_T MPI_SHORT
500 #ifndef OTF2_MPI_UINT32_T
501 # if MPI_VERSION >= 3
502 # define OTF2_MPI_UINT32_T MPI_UINT32_T
504 # define OTF2_MPI_UINT32_T MPI_UNSIGNED
515 #ifndef OTF2_MPI_INT32_T
516 # if MPI_VERSION >= 3
517 # define OTF2_MPI_INT32_T MPI_INT32_T
519 # define OTF2_MPI_INT32_T MPI_INT
531 #ifndef OTF2_MPI_UINT64_T
532 # define OTF2_MPI_UINT64_T MPI_UINT64_T
534 # error Please define OTF2_MPI_UINT64_T to a suitable MPI datatype for uint64_t.
545 #ifndef OTF2_MPI_INT64_T
546 # define OTF2_MPI_INT64_T MPI_INT64_T
548 # error Please define OTF2_MPI_INT64 to a suitable MPI datatype for int64_t.
559 #ifndef OTF2_MPI_FLOAT
560 # define OTF2_MPI_FLOAT MPI_FLOAT
570 #ifndef OTF2_MPI_DOUBLE
571 # define OTF2_MPI_DOUBLE MPI_DOUBLE
587 int displacements[ 1 ];
593 typedef struct OTF2_MPI_UserData
606 otf2_mpi_create_context( MPI_Comm comm,
616 uint32_t numberOfFiles );
625 OTF2_MPI_UserData* user_data = NULL;
635 if ( MPI_COMM_NULL == globalComm )
640 user_data = ( OTF2_MPI_UserData* )calloc( 1,
sizeof( *user_data ) );
646 otf2_mpi_get_collectives( &user_data->callbacks );
648 user_data->global = otf2_mpi_create_context( globalComm,
true );
649 if ( !user_data->global )
655 if ( MPI_COMM_NULL != localComm )
657 user_data->local = otf2_mpi_create_context( localComm,
true );
658 if ( !user_data->local )
666 &user_data->callbacks,
674 otf2_mpi_destroy_context( user_data->local );
675 otf2_mpi_destroy_context( user_data->global );
686 uint32_t numberOfFiles )
689 OTF2_MPI_UserData* user_data = NULL;
699 if ( MPI_COMM_NULL == globalComm )
704 user_data = ( OTF2_MPI_UserData* )calloc( 1,
sizeof( *user_data ) );
710 otf2_mpi_get_collectives( &user_data->callbacks );
712 user_data->global = otf2_mpi_create_context( globalComm,
true );
713 if ( !user_data->global )
719 user_data->local = otf2_mpi_split_context_by_number( user_data->global,
721 if ( !user_data->local )
728 &user_data->callbacks,
736 otf2_mpi_destroy_context( user_data->local );
737 otf2_mpi_destroy_context( user_data->global );
747 MPI_Comm globalComm )
750 OTF2_MPI_UserData* user_data = NULL;
760 if ( MPI_COMM_NULL == globalComm )
765 user_data = ( OTF2_MPI_UserData* )calloc( 1,
sizeof( *user_data ) );
771 otf2_mpi_get_collectives( &user_data->callbacks );
773 user_data->global = otf2_mpi_create_context( globalComm,
true );
774 if ( !user_data->global )
781 &user_data->callbacks,
789 otf2_mpi_destroy_context( user_data->global );
798 otf2_mpi_create_context( MPI_Comm comm,
804 ret = CALL_MPI( MPI_Comm_size ) ( comm, &size );
805 if ( MPI_SUCCESS != ret )
812 + ( ( size - 1 ) *
sizeof(
int ) ) );
818 new_context->size = size;
819 ret = CALL_MPI( MPI_Comm_rank ) ( comm, &new_context->rank );
820 if ( MPI_SUCCESS != ret )
828 ret = CALL_MPI( MPI_Comm_dup ) ( comm, &new_context->comm );
829 if ( MPI_SUCCESS != ret )
837 new_context->comm = comm;
847 if ( !collectiveContext )
852 CALL_MPI( MPI_Comm_free ) ( &collectiveContext->comm );
854 free( collectiveContext );
866 ret = CALL_MPI( MPI_Comm_split ) ( commContext->comm,
870 if ( MPI_SUCCESS != ret )
875 new_context = otf2_mpi_create_context( new_comm,
false );
878 CALL_MPI( MPI_Comm_free ) ( &new_comm );
888 uint32_t numberOfFiles )
891 int rem = commContext->size % numberOfFiles;
892 int local_size = commContext->size / numberOfFiles + !!rem;
896 for ( i = 0; i < commContext->rank; i++ )
899 if ( local_root + local_size == i + 1 )
901 local_root += local_size;
903 local_size -= file_number == rem;
908 return otf2_mpi_split_context( commContext,
917 #define case_return( TYPE, MPI_SUFFIX ) \
918 case OTF2_TYPE_ ## TYPE: \
919 return OTF2_MPI_ ## TYPE ## MPI_SUFFIX
922 case_return( UINT8, _T );
923 case_return( INT8, _T );
924 case_return( UINT16, _T );
925 case_return( INT16, _T );
926 case_return( UINT32, _T );
927 case_return( INT32, _T );
928 case_return( UINT64, _T );
929 case_return( INT64, _T );
930 case_return( FLOAT, );
931 case_return( DOUBLE, );
933 return MPI_DATATYPE_NULL;
940 otf2_mpi_collectives_release(
void* userData,
944 OTF2_MPI_UserData* user_data = ( OTF2_MPI_UserData* )userData;
946 ( void )globalCommContext;
947 ( void )localCommContext;
949 otf2_mpi_destroy_context( user_data->global );
950 otf2_mpi_destroy_context( user_data->local );
956 otf2_mpi_collectives_create_local_comm(
void* userData,
964 uint32_t numberOfFiles )
970 ( void )numberOfFiles;
972 *localCommContextOut = otf2_mpi_split_context( globalCommContext,
976 return *localCommContextOut
983 otf2_mpi_collectives_free_local_comm(
void* userData,
988 otf2_mpi_destroy_context( localCommContext );
995 otf2_mpi_collectives_get_size(
void* userData,
1001 *size = commContext->size;
1008 otf2_mpi_collectives_get_rank(
void* userData,
1014 *rank = commContext->rank;
1021 otf2_mpi_collectives_barrier(
void* userData,
1028 ret = CALL_MPI( MPI_Barrier ) ( commContext->comm );
1030 return MPI_SUCCESS == ret
1037 otf2_mpi_collectives_bcast(
void* userData,
1040 uint32_t numberElements,
1048 ret = CALL_MPI( MPI_Bcast ) ( data,
1050 otf2_mpi_get_type( type ),
1052 commContext->comm );
1054 return MPI_SUCCESS == ret
1061 otf2_mpi_collectives_gather(
void* userData,
1065 uint32_t numberElements,
1073 ret = CALL_MPI( MPI_Gather ) ( (
void* )inData,
1075 otf2_mpi_get_type( type ),
1078 otf2_mpi_get_type( type ),
1080 commContext->comm );
1082 return MPI_SUCCESS == ret
1089 otf2_mpi_collectives_gatherv(
void* userData,
1092 uint32_t inElements,
1094 const uint32_t* outElements,
1103 if ( (
int )root == commContext->rank )
1107 for ( i = 0; i < commContext->rank; ++i )
1109 commContext->displacements[ i ] = displ;
1110 displ += outElements[ i ];
1112 displs = commContext->displacements;
1115 ret = CALL_MPI( MPI_Gatherv ) ( (
void* )inData,
1117 otf2_mpi_get_type( type ),
1119 (
int* )outElements,
1121 otf2_mpi_get_type( type ),
1123 commContext->comm );
1125 return MPI_SUCCESS == ret
1132 otf2_mpi_collectives_scatter(
void* userData,
1136 uint32_t numberElements,
1142 int ret = CALL_MPI( MPI_Scatter ) ( (
void* )inData,
1144 otf2_mpi_get_type( type ),
1147 otf2_mpi_get_type( type ),
1149 commContext->comm );
1151 return MPI_SUCCESS == ret
1158 otf2_mpi_collectives_scatterv(
void* userData,
1161 const uint32_t* inElements,
1163 uint32_t outElements,
1171 if ( (
int )root == commContext->rank )
1175 for ( i = 0; i < commContext->rank; ++i )
1177 commContext->displacements[ i ] = displ;
1178 displ += inElements[ i ];
1180 displs = commContext->displacements;
1183 int ret = CALL_MPI( MPI_Scatterv ) ( (
void* )inData,
1186 otf2_mpi_get_type( type ),
1189 otf2_mpi_get_type( type ),
1191 commContext->comm );
1193 return MPI_SUCCESS == ret
1202 collectiveCallbacks->otf2_release = otf2_mpi_collectives_release;
1203 collectiveCallbacks->otf2_get_size = otf2_mpi_collectives_get_size;
1204 collectiveCallbacks->otf2_get_rank = otf2_mpi_collectives_get_rank;
1205 collectiveCallbacks->otf2_create_local_comm = otf2_mpi_collectives_create_local_comm;
1206 collectiveCallbacks->otf2_free_local_comm = otf2_mpi_collectives_free_local_comm;
1207 collectiveCallbacks->otf2_barrier = otf2_mpi_collectives_barrier;
1208 collectiveCallbacks->otf2_bcast = otf2_mpi_collectives_bcast;
1209 collectiveCallbacks->otf2_gather = otf2_mpi_collectives_gather;
1210 collectiveCallbacks->otf2_gatherv = otf2_mpi_collectives_gatherv;
1211 collectiveCallbacks->otf2_scatter = otf2_mpi_collectives_scatter;
1212 collectiveCallbacks->otf2_scatterv = otf2_mpi_collectives_scatterv;
1217 #ifdef OTF2_MPI_USE_PMPI_undef_me
1218 #undef OTF2_MPI_USE_PMPI
1219 #undef OTF2_MPI_USE_PMPI_undef_me
Record reading can continue.
Definition: OTF2_GeneralDefinitions.h:352
Main include file for applications using OTF2.
uint8_t OTF2_Type
Wrapper for enum OTF2_Type_enum.
Definition: OTF2_GeneralDefinitions.h:596
Definition: OTF2_ErrorCodes.h:65
Definition: OTF2_ErrorCodes.h:230
Definition: OTF2_ErrorCodes.h:244
Struct which holds all collective callbacks.
Definition: OTF2_Callbacks.h:497
OTF2_ErrorCode OTF2_Reader_SetCollectiveCallbacks(OTF2_Reader *reader, const OTF2_CollectiveCallbacks *collectiveCallbacks, void *collectiveData, OTF2_CollectiveContext *globalCommContext, OTF2_CollectiveContext *localCommContext)
Set the collective callbacks for the reader.
OTF2_ErrorCode
Definition: OTF2_ErrorCodes.h:53
OTF2_CallbackCode
Return value to indicate that the record reading should be interrupted.
Definition: OTF2_GeneralDefinitions.h:349
Signaling an error in the callback.
Definition: OTF2_GeneralDefinitions.h:363
struct OTF2_Archive_struct OTF2_Archive
Keeps all meta-data for an OTF2 archive.
Definition: OTF2_Archive.h:220
struct OTF2_Reader_struct OTF2_Reader
Keeps all necessary information for the reader.
Definition: OTF2_Reader.h:193
static OTF2_ErrorCode OTF2_MPI_Archive_SetCollectiveCallbacks(OTF2_Archive *archive, MPI_Comm globalComm, MPI_Comm localComm)
Register an MPI collective context to an OTF2 archive.
static OTF2_ErrorCode OTF2_MPI_Reader_SetCollectiveCallbacks(OTF2_Reader *reader, MPI_Comm globalComm)
Register an MPI collective context to an OTF2 reader.
static OTF2_ErrorCode OTF2_MPI_Archive_SetCollectiveCallbacksSplit(OTF2_Archive *archive, MPI_Comm globalComm, uint32_t numberOfFiles)
Register an MPI collective context to an OTF2 archive.
struct OTF2_CollectiveContext OTF2_CollectiveContext
User provided type for collective groups.
Definition: OTF2_Callbacks.h:310
OTF2_ErrorCode OTF2_Archive_SetCollectiveCallbacks(OTF2_Archive *archive, const OTF2_CollectiveCallbacks *collectiveCallbacks, void *collectiveData, OTF2_CollectiveContext *globalCommContext, OTF2_CollectiveContext *localCommContext)
Set the collective callbacks for the archive.
Definition: OTF2_ErrorCodes.h:246