瀏覽代碼

Fix crash when using several workers per CUDA device

Samuel Thibault 8 年之前
父節點
當前提交
4eff786660
共有 1 個文件被更改,包括 7 次插入3 次删除
  1. 7 3
      src/core/topology.c

+ 7 - 3
src/core/topology.c

@@ -1089,9 +1089,13 @@ _starpu_init_machine_config(struct _starpu_machine_config *config, int no_mp_con
 			config->worker_mask |= STARPU_CUDA;
 
 			struct handle_entry *entry;
-			_STARPU_MALLOC(entry, sizeof(*entry));
-			entry->gpuid = devid;
-			HASH_ADD_INT(devices_using_cuda, gpuid, entry);
+			HASH_FIND_INT(devices_using_cuda, &devid, entry);
+			if (!entry)
+			{
+				_STARPU_MALLOC(entry, sizeof(*entry));
+				entry->gpuid = devid;
+				HASH_ADD_INT(devices_using_cuda, gpuid, entry);
+			}
 		}
 
 #ifndef STARPU_SIMGRID