@@ -115,28 +115,33 @@ int main (int argc, char** argv)
115
115
{
116
116
int rank;
117
117
int n_ranks;
118
+ bool is_managed_local = false ;
118
119
unsigned seed = 0u ;
119
120
unsigned n_epochs = 3u ;
120
121
int rc = 0 ;
121
122
std::string list_name;
122
123
std::string managed_dir;
123
124
124
- if ((argc != 3 ) && (argc != 4 ) && (argc != 5 )) {
125
- cout << " usage: " << argv[0 ] << " list_file managed_dir [n_epochs [seed]]"
125
+ if ((argc < 4 ) || (argc > 6 )) {
126
+ cout << " usage: " << argv[0 ] << " list_file managed_dir is_local [n_epochs [seed]]"
126
127
<< endl;
127
- cout << " if seed is not given, a random seed is used" << endl;
128
+ cout << " list_file: constains a list of files to be generated and used," << endl
129
+ << " one per line, without managed_dir prefix." << endl;
130
+ cout << " is_local: indicates if the managed_dir is local (1) or shared (0)" << endl;
131
+ cout << " seed: if not given, a random seed is used" << endl;
128
132
return EXIT_SUCCESS;
129
133
}
130
134
131
135
list_name = argv[1 ];
132
136
managed_dir = argv[2 ];
137
+ is_managed_local = static_cast <bool > (atoi (argv[3 ]));
133
138
134
139
if (argc == 4 ) {
135
- n_epochs = static_cast <unsigned > (atoi (argv[3 ]));
140
+ n_epochs = static_cast <unsigned > (atoi (argv[4 ]));
136
141
}
137
142
138
143
if (argc == 5 ) {
139
- seed = static_cast <unsigned > (atoi (argv[4 ]));
144
+ seed = static_cast <unsigned > (atoi (argv[5 ]));
140
145
}
141
146
142
147
std::vector<std::string> flist;
@@ -155,7 +160,17 @@ int main (int argc, char** argv)
155
160
return rc;
156
161
}
157
162
158
- if (rank == 0 ) { // if directory is local, everyone should do
163
+ if (is_managed_local) { // if directory is local, everyone should create
164
+ mode_t m = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH | S_ISGID);
165
+ int c = mkdir_as_needed (managed_dir.c_str (), m);
166
+ if (c < 0 ) {
167
+ cout << " Rank " << rank
168
+ << " could not create directory: '" << managed_dir << " '" << endl;
169
+ MPI_Abort (MPI_COMM_WORLD, errno);
170
+ return EXIT_FAILURE;
171
+ }
172
+ }
173
+ else if (rank == 0 ) {
159
174
mode_t m = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH | S_ISGID);
160
175
int c = mkdir_as_needed (managed_dir.c_str (), m);
161
176
if (c < 0 ) {
0 commit comments