aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f>2011-09-17 20:01:53 +0000
committereschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f>2011-09-17 20:01:53 +0000
commitd08ad86c184d8c128bbb9a4e5dfafa4c555ecce2 (patch)
tree981603fe1aa28ed99241b7b5cf385ed8619071c0
parent1dad28881996abb18b8eff98b034eecb58af0090 (diff)
Output Formaline tarballs in parallel
Output the Formaline tarballs in parallel, distributed over all MPI processes. This may improve startup time when running with many processes and if there is a parallel file system. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@208 83718e91-0e4f-0410-abf4-91180603181f
-rw-r--r--src/output_source.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/output_source.c b/src/output_source.c
index 43e3632..a4ca9c7 100644
--- a/src/output_source.c
+++ b/src/output_source.c
@@ -34,12 +34,14 @@ Formaline_OutputSource (CCTK_ARGUMENTS)
DECLARE_CCTK_ARGUMENTS;
DECLARE_CCTK_PARAMETERS;
+ size_t myproc, nprocs;
char filename [10000];
FILE * file;
size_t count;
struct datainfo const * datainfo;
- if (CCTK_MyProc (cctkGH) != 0) return;
+ myproc = CCTK_MyProc (cctkGH);
+ nprocs = CCTK_nProcs (cctkGH);
{ CCTK_PRINTSEPARATOR }
CCTK_VInfo (CCTK_THORNSTRING,
@@ -53,6 +55,8 @@ Formaline_OutputSource (CCTK_ARGUMENTS)
/* Output all thorns' tarballs */
for (count = 0; cactus_source[count]; ++ count)
{
+ if (count % nprocs != myproc) continue;
+
snprintf (filename, sizeof filename,
"%s/%s/Cactus-source-%s.tar.gz",
out_dir, output_source_subdirectory,
@@ -73,15 +77,17 @@ Formaline_OutputSource (CCTK_ARGUMENTS)
}
/* Add a README */
- snprintf (filename, sizeof filename,
- "%s/%s/README", out_dir, output_source_subdirectory);
- file = fopen (filename, "w");
- if (file == NULL)
+ if (myproc == nprocs - 1)
{
- CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Failed to open README file \"%s\" for writing", filename);
- }
- fprintf (file,
+ snprintf (filename, sizeof filename,
+ "%s/%s/README", out_dir, output_source_subdirectory);
+ file = fopen (filename, "w");
+ if (file == NULL)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Failed to open README file \"%s\" for writing", filename);
+ }
+ fprintf (file,
"README for the Cactus source tree\n"
"\n"
"This directory contains a complete Cactus source tree in several tarballs.\n"
@@ -99,6 +105,7 @@ Formaline_OutputSource (CCTK_ARGUMENTS)
"\n"
"The files \"config-info\" and \"ThornList\" that were used to build the\n"
"executable can then be found in the \"configs\" subdirectory.\n"
- );
- fclose (file);
+ );
+ fclose (file);
+ }
}