소스 검색

write_bus_affinity_file_content: Do not open the file if there is nothing to write.

This fixes a resource leak : the file use to be always opened, but not always closed.
Cyril Roelandt 13 년 전
부모
커밋
f00cc9ea86
1개의 변경된 파일2개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 4
      src/core/perfmodel/perfmodel_bus.c

+ 2 - 4
src/core/perfmodel/perfmodel_bus.c

@@ -662,13 +662,12 @@ static void load_bus_affinity_file_content(void)
 
 static void write_bus_affinity_file_content(void)
 {
-	FILE *f;
-
 	STARPU_ASSERT(was_benchmarked);
 
+#if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
+	FILE *f;
 	char path[256];
 	get_affinity_path(path, 256);
-
 	f = fopen(path, "w+");
 	if (!f)
 	{
@@ -678,7 +677,6 @@ static void write_bus_affinity_file_content(void)
 		STARPU_ABORT();
 	}
 
-#if defined(STARPU_USE_CUDA) || defined(STARPU_USE_OPENCL)
 	unsigned cpu;
         int gpu;