|
@@ -783,6 +783,8 @@ static void load_bus_affinity_file_content(void)
|
|
|
f = fopen(path, "r");
|
|
|
STARPU_ASSERT(f);
|
|
|
|
|
|
+ _starpu_frdlock(f);
|
|
|
+
|
|
|
struct _starpu_machine_config *config = _starpu_get_machine_config();
|
|
|
ncpus = _starpu_topology_get_nhwcpu(config);
|
|
|
unsigned gpu;
|
|
@@ -835,6 +837,7 @@ static void load_bus_affinity_file_content(void)
|
|
|
STARPU_ASSERT(ret == 0);
|
|
|
}
|
|
|
#endif /* !STARPU_USE_OPENCL */
|
|
|
+ _starpu_frdunlock(f);
|
|
|
|
|
|
fclose(f);
|
|
|
#endif /* !(STARPU_USE_CUDA_ || STARPU_USE_OPENCL */
|
|
@@ -862,6 +865,7 @@ static void write_bus_affinity_file_content(void)
|
|
|
STARPU_ABORT();
|
|
|
}
|
|
|
|
|
|
+ _starpu_frdlock(f);
|
|
|
unsigned cpu;
|
|
|
unsigned gpu;
|
|
|
|
|
@@ -897,6 +901,7 @@ static void write_bus_affinity_file_content(void)
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ _starpu_frdunlock(f);
|
|
|
fclose(f);
|
|
|
#endif
|
|
|
}
|
|
@@ -1006,6 +1011,7 @@ static int load_bus_latency_file_content(void)
|
|
|
fflush(stderr);
|
|
|
STARPU_ABORT();
|
|
|
}
|
|
|
+ _starpu_frdlock(f);
|
|
|
|
|
|
for (src = 0; src < STARPU_MAXNODES; src++)
|
|
|
{
|
|
@@ -1073,13 +1079,14 @@ static int load_bus_latency_file_content(void)
|
|
|
break;
|
|
|
ungetc(n, f);
|
|
|
}
|
|
|
+ _starpu_frdunlock(f);
|
|
|
+ fclose(f);
|
|
|
|
|
|
/* No more values, take NAN */
|
|
|
for ( ; src < STARPU_MAXNODES; src++)
|
|
|
for (dst = 0; dst < STARPU_MAXNODES; dst++)
|
|
|
latency_matrix[src][dst] = NAN;
|
|
|
|
|
|
- fclose(f);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -1104,6 +1111,8 @@ static void write_bus_latency_file_content(void)
|
|
|
fflush(stderr);
|
|
|
STARPU_ABORT();
|
|
|
}
|
|
|
+ _starpu_fwrlock(f);
|
|
|
+ _starpu_ftruncate(f);
|
|
|
|
|
|
fprintf(f, "# ");
|
|
|
for (dst = 0; dst < STARPU_MAXNODES; dst++)
|
|
@@ -1163,6 +1172,7 @@ static void write_bus_latency_file_content(void)
|
|
|
|
|
|
fprintf(f, "\n");
|
|
|
}
|
|
|
+ _starpu_fwrunlock(f);
|
|
|
|
|
|
fclose(f);
|
|
|
}
|
|
@@ -1223,6 +1233,7 @@ static int load_bus_bandwidth_file_content(void)
|
|
|
fflush(stderr);
|
|
|
STARPU_ABORT();
|
|
|
}
|
|
|
+ _starpu_frdlock(f);
|
|
|
|
|
|
for (src = 0; src < STARPU_MAXNODES; src++)
|
|
|
{
|
|
@@ -1290,13 +1301,14 @@ static int load_bus_bandwidth_file_content(void)
|
|
|
break;
|
|
|
ungetc(n, f);
|
|
|
}
|
|
|
+ _starpu_frdunlock(f);
|
|
|
+ fclose(f);
|
|
|
|
|
|
/* No more values, take NAN */
|
|
|
for ( ; src < STARPU_MAXNODES; src++)
|
|
|
for (dst = 0; dst < STARPU_MAXNODES; dst++)
|
|
|
latency_matrix[src][dst] = NAN;
|
|
|
|
|
|
- fclose(f);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -1316,6 +1328,9 @@ static void write_bus_bandwidth_file_content(void)
|
|
|
f = fopen(path, "w+");
|
|
|
STARPU_ASSERT(f);
|
|
|
|
|
|
+ _starpu_fwrlock(f);
|
|
|
+ _starpu_ftruncate(f);
|
|
|
+
|
|
|
fprintf(f, "# ");
|
|
|
for (dst = 0; dst < STARPU_MAXNODES; dst++)
|
|
|
fprintf(f, "to %d\t\t", dst);
|
|
@@ -1387,6 +1402,7 @@ static void write_bus_bandwidth_file_content(void)
|
|
|
fprintf(f, "\n");
|
|
|
}
|
|
|
|
|
|
+ _starpu_fwrunlock(f);
|
|
|
fclose(f);
|
|
|
}
|
|
|
#endif /* STARPU_SIMGRID */
|
|
@@ -1551,6 +1567,7 @@ static void check_bus_config_file(void)
|
|
|
// Loading configuration from file
|
|
|
f = fopen(path, "r");
|
|
|
STARPU_ASSERT(f);
|
|
|
+ _starpu_frdlock(f);
|
|
|
_starpu_drop_comments(f);
|
|
|
ret = fscanf(f, "%u\t", &read_cpus);
|
|
|
STARPU_ASSERT(ret == 1);
|
|
@@ -1565,6 +1582,7 @@ static void check_bus_config_file(void)
|
|
|
if (ret == 0)
|
|
|
read_mic = 0;
|
|
|
_starpu_drop_comments(f);
|
|
|
+ _starpu_frdunlock(f);
|
|
|
fclose(f);
|
|
|
|
|
|
// Loading current configuration
|
|
@@ -1619,6 +1637,8 @@ static void write_bus_config_file_content(void)
|
|
|
|
|
|
f = fopen(path, "w+");
|
|
|
STARPU_ASSERT(f);
|
|
|
+ _starpu_fwrlock(f);
|
|
|
+ _starpu_ftruncate(f);
|
|
|
|
|
|
fprintf(f, "# Current configuration\n");
|
|
|
fprintf(f, "%u # Number of CPUs\n", ncpus);
|
|
@@ -1626,6 +1646,7 @@ static void write_bus_config_file_content(void)
|
|
|
fprintf(f, "%d # Number of OpenCL devices\n", nopencl);
|
|
|
fprintf(f, "%d # Number of MIC devices\n", nmic);
|
|
|
|
|
|
+ _starpu_fwrunlock(f);
|
|
|
fclose(f);
|
|
|
}
|
|
|
|
|
@@ -1664,6 +1685,8 @@ static void write_bus_platform_file_content(void)
|
|
|
fflush(stderr);
|
|
|
STARPU_ABORT();
|
|
|
}
|
|
|
+ _starpu_fwrlock(f);
|
|
|
+ _starpu_ftruncate(f);
|
|
|
|
|
|
fprintf(f,
|
|
|
"<?xml version='1.0'?>\n"
|
|
@@ -1810,6 +1833,7 @@ static void write_bus_platform_file_content(void)
|
|
|
" </platform>\n"
|
|
|
);
|
|
|
|
|
|
+ _starpu_fwrunlock(f);
|
|
|
fclose(f);
|
|
|
}
|
|
|
|