void mpi_comm_get_name_ (int* comm, char* name, int* len, int* ierr){
*ierr = MPI_Comm_get_name(simgrid::smpi::Comm::f2c(*comm), name, len);
if(*len>0)
- name[*len]=' ';
+ for(int i = *len; i<MPI_MAX_OBJECT_NAME+1; i++)
+ name[i]=' ';
}
void mpi_comm_compare_ (int* comm1, int* comm2, int *result, int* ierr){
*ierr = MPI_Comm_remote_size(simgrid::smpi::Comm::f2c(*comm), size);
}
-void mpi_comm_set_name_ (int* comm, char* name, int* ierr, int size){
- char* tname = xbt_new(char, size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
+void mpi_comm_set_name_ (int* comm, char* name, int* ierr){
+ int count;
+ for(count=MPI_MAX_OBJECT_NAME-1; count>=0 && name[count]==' '; count--);
+ count+=1;
+ char* tname = xbt_new(char, count+1);
+ strncpy(tname, name, count);
+ tname[count]='\0';
*ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
xbt_free(tname);
}
WRAPPED_PMPI_CALL(int,MPI_Comm_free,(MPI_Comm * comm),(comm))
WRAPPED_PMPI_CALL(int,MPI_Comm_get_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag),(comm, comm_keyval, attribute_val, flag))
WRAPPED_PMPI_CALL(int,MPI_Comm_get_name ,(MPI_Comm comm, char* name, int* len),(comm, name, len))
+WRAPPED_PMPI_CALL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name))
WRAPPED_PMPI_CALL(int,MPI_Comm_group,(MPI_Comm comm, MPI_Group * group),(comm, group))
WRAPPED_PMPI_CALL(int,MPI_Comm_rank,(MPI_Comm comm, int *rank),(comm, rank))
WRAPPED_PMPI_CALL(int,MPI_Comm_set_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val),( comm, comm_keyval, attribute_val))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_remote_size,(MPI_Comm comm, int* size) ,(comm, size))
UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_errhandler,(MPI_Comm comm, MPI_Errhandler errhandler) ,(comm, errhandler))
UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_info ,(MPI_Comm comm, MPI_Info info),(comm, info))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
}
}
+int PMPI_Comm_set_name (MPI_Comm comm, char* name)
+{
+ if (comm == MPI_COMM_NULL) {
+ return MPI_ERR_COMM;
+ } else if (name == nullptr) {
+ return MPI_ERR_ARG;
+ } else {
+ comm->set_name(name);
+ return MPI_SUCCESS;
+ }
+}
+
int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
{
if (comm == MPI_COMM_NULL) {
void mpi_type_create_subarray_(int* ndims, int* array_of_sizes, int* array_of_subsizes, int* array_of_starts,
int* order, int* oldtype, int* newtype, int* ierr);
void mpi_type_match_size_(int* typeclass, int* size, int* datatype, int* ierr);
-void mpi_comm_set_name_(int* comm, char* name, int* ierr, int size);
+void mpi_comm_set_name_(int* comm, char* name, int* ierr);
void mpi_comm_dup_with_info_(int* comm, int* info, int* newcomm, int* ierr);
void mpi_comm_split_type_(int* comm, int* split_type, int* key, int* info, int* newcomm, int* ierr);
void mpi_comm_set_info_(int* comm, int* info, int* ierr);
int is_blocked_; // are ranks allocated on the same smp node contiguous ?
int is_smp_comm_; // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursivity
std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
+ std::string name_;
public:
static std::unordered_map<int, smpi_key_elem> keyvals_;
int size();
int rank();
void get_name(char* name, int* len);
+ void set_name(char* name);
void set_leaders_comm(MPI_Comm leaders);
void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
int* get_non_uniform_map();
smpi_process()->comm_world()->get_name(name, len);
return;
}
- if(this == MPI_COMM_WORLD) {
- strncpy(name, "WORLD", 6);
- *len = 5;
+ if(this == MPI_COMM_WORLD && name_.empty()) {
+ strncpy(name, "MPI_COMM_WORLD", 15);
+ *len = 14;
+ } else if(this == MPI_COMM_SELF && name_.empty()) {
+ strncpy(name, "MPI_COMM_SELF", 14);
+ *len = 13;
} else {
- *len = snprintf(name, MPI_MAX_NAME_STRING, "%p", this);
+ *len = snprintf(name, MPI_MAX_NAME_STRING+1, "%s", name_.c_str());
}
}
+void Comm::set_name (char* name)
+{
+ if (this == MPI_COMM_UNINITIALIZED){
+ smpi_process()->comm_world()->set_name(name);
+ return;
+ }
+ name_.replace (0, MPI_MAX_NAME_STRING+1, name);
+}
+
+
void Comm::set_leaders_comm(MPI_Comm leaders){
if (this == MPI_COMM_UNINITIALIZED){
smpi_process()->comm_world()->set_leaders_comm(leaders);
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include/")
foreach(file cmfree cmsplit2 cmsplit cmsplit_type commcreate1 comm_create_group comm_group_half comm_group_rand
- comm_info ctxalloc ctxsplit dup dup_with_info)
+ comm_info ctxalloc ctxsplit dup dup_with_info commname)
# not compiled files
- # comm_idup comm_idup_mul comm_idup_overlap commname dupic ic1 ic2 iccreate icgroup icm icsplit probe-intercomm
+ # comm_idup comm_idup_mul comm_idup_overlap dupic ic1 ic2 iccreate icgroup icm icsplit probe-intercomm
add_executable(${file} EXCLUDE_FROM_ALL ${file}.c)
add_dependencies(tests ${file})
target_link_libraries(${file} simgrid mtest_c)
#works, but needs MPI_Comm_set_name
commcreate1 8
commcreate1 1
-#needs MPI_Comm_set_name and MPI_Intercomm_create
-#commname 4
+commname 4
#ic1 4
# ic2 needs an unusually large number of processes (>= 33)
#ic2 33
include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
# add_executable(commerrf EXCLUDE_FROM_ALL commerrf.f)
- # add_executable(commnamef EXCLUDE_FROM_ALL commnamef.f)
-
- # add_dependencies(tests commerrf commnamef)
+ add_executable(commnamef EXCLUDE_FROM_ALL commnamef.f)
+ add_dependencies(tests commnamef)
+ # add_dependencies(tests commerrf)
# target_link_libraries(commerrf simgrid mtest_f77)
- # target_link_libraries(commnamef simgrid mtest_f77)
+ target_link_libraries(commnamef simgrid mtest_f77)
endif()
set(examples_src
-#commnamef 2
+commnamef 2
#commerrf 2
#io
rma
init
-#comm
+comm
ext
topo
if (!getinter) {
idx = MTestGetIntracomm(comm, min_size);
- if (idx == 0) {
- getinter = 1;
- }
+/* if (idx == 0) {*/
+/* getinter = 1;*/
+/* }*/
}
if (getinter) {
int isLeft;