diff --git a/.gitignore b/.gitignore index d5a3234c96bb459e2f5bb7aaa90b92fa2b99cca9..516768ebefdda0935cc28e7a4bf86e3f627708ac 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ frontend/ *.pyc *.egg-info .vscode -docs/_build \ No newline at end of file +docs/_build +.cache \ No newline at end of file diff --git a/GenericIO.cxx b/GenericIO.cxx index 77d8380e9edada948279270a3e9a995bfec1333f..ac00f34cead32e317ad408ae62df1303abdcbf39 100644 --- a/GenericIO.cxx +++ b/GenericIO.cxx @@ -1867,7 +1867,13 @@ void GenericIO::setNaturalDefaultPartition() { #ifdef __bgq__ DefaultPartition = MPIX_IO_link_id(); #elif !defined(GENERICIO_NO_MPI) - bool UseName = true; + + int rank, nranks; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &nranks); + + // assign by 8bit hash of MPI_Get_processor_name + bool UseName = false; const char *EnvStr = getenv("GENERICIO_PARTITIONS_USE_NAME"); if (EnvStr) { int Mod = atoi(EnvStr); @@ -1888,15 +1894,26 @@ void GenericIO::setNaturalDefaultPartition() { DefaultPartition = color; } - // This is for debugging. + // assign round robin to max number given by GENERICIO_RANK_PARTITIONS + int roundRobinAssign = 0; EnvStr = getenv("GENERICIO_RANK_PARTITIONS"); if (EnvStr) { - int Mod = atoi(EnvStr); - if (Mod > 0) { - int Rank; - MPI_Comm_rank(MPI_COMM_WORLD, &Rank); - DefaultPartition += Rank % Mod; - } + roundRobinAssign = atoi(EnvStr); + } + + // default: one file per rank, up to 256 files. Warn if we combine ranks in + // single file + if(!UseName && (roundRobinAssign==0)) { + if(rank == 0 && nranks > 256) + std::cerr << "WARNING: Running with more than 256 MPI ranks, and " + << "GENERICIO_RANK_PARTITIONS is not set.\n" + << "GenericIO will limit the number of file partitions to 256" + << std::endl; + roundRobinAssign = 256; + } + + if (roundRobinAssign > 0) { + DefaultPartition = rank % roundRobinAssign; } #endif #ifdef GENERICIO_WITH_VELOC