Samuel Thibault преди 9 години
родител
ревизия
ed431c73a5
променени са 2 файла, в които са добавени 11 реда и са изтрити 2 реда
  1. 7 0
      src/core/disk_ops/disk_stdio.c
  2. 4 2
      src/core/disk_ops/unistd/disk_unistd_global.c

+ 7 - 0
src/core/disk_ops/disk_stdio.c

@@ -382,6 +382,7 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 
 		if (!f)
 			f = _starpu_stdio_reopen(tmp);
+
 		/* clean cache memory */
 		int res = fflush(f);
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
@@ -392,6 +393,9 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 		res = fsync(fileno(f));
 #endif
 		STARPU_ASSERT_MSG(res == 0, "Slowness computation failed \n");
+
+		if (!tmp->file)
+			_starpu_stdio_reclose(f);
 	}
 	end = starpu_timing_now();
 	timing_slowness = end - start;
@@ -424,6 +428,9 @@ static int get_stdio_bandwidth_between_disk_and_main_ram(unsigned node)
 		res = fsync(fileno(f));
 #endif
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
+
+		if (!tmp->file)
+			_starpu_stdio_reclose(f);
 	}
 	end = starpu_timing_now();
 	timing_latency = end - start;

+ 4 - 2
src/core/disk_ops/unistd/disk_unistd_global.c

@@ -429,12 +429,13 @@ int get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 
 		if (fd < 0)
 			fd = _starpu_unistd_reopen(tmp);
-
 #ifdef STARPU_HAVE_WINDOWS
 		res = _commit(fd);
 #else
 		res = fsync(fd);
 #endif
+		if (tmp->descriptor < 0)
+			_starpu_unistd_reclose(fd);
 
 		STARPU_ASSERT_MSG(res == 0, "bandwidth computation failed");
 	}
@@ -459,12 +460,13 @@ int get_unistd_global_bandwidth_between_disk_and_main_ram(unsigned node)
 
 		if (fd < 0)
 			fd = _starpu_unistd_reopen(tmp);
-
 #ifdef STARPU_HAVE_WINDOWS
 		res = _commit(fd);
 #else
 		res = fsync(fd);
 #endif
+		if (tmp->descriptor < 0)
+			_starpu_unistd_reclose(fd);
 
 		STARPU_ASSERT_MSG(res == 0, "Latency computation failed");
 	}