Explorar o código

Fix build without CPUs by moving _starpu_cpu_get_global_mem_size to where it is now used

Samuel Thibault %!s(int64=7) %!d(string=hai) anos
pai
achega
83651b26fa
Modificáronse 3 ficheiros con 64 adicións e 65 borrados
  1. 64 0
      src/core/topology.c
  2. 0 64
      src/drivers/cpu/driver_cpu.c
  3. 0 1
      src/drivers/cpu/driver_cpu.h

+ 64 - 0
src/core/topology.c

@@ -1976,6 +1976,70 @@ static void _starpu_init_binding_cpu(struct _starpu_machine_config *config)
 	}
 }
 
+static size_t _starpu_cpu_get_global_mem_size(int nodeid STARPU_ATTRIBUTE_UNUSED, struct _starpu_machine_config *config STARPU_ATTRIBUTE_UNUSED)
+{
+	size_t global_mem;
+	starpu_ssize_t limit = -1;
+
+#if defined(STARPU_HAVE_HWLOC)
+	struct _starpu_machine_topology *topology = &config->topology;
+
+	if (starpu_get_env_number_default("STARPU_USE_NUMA", 0))
+	{
+		int depth_node = hwloc_get_type_depth(topology->hwtopology, HWLOC_OBJ_NUMANODE);
+
+		if (depth_node == HWLOC_TYPE_DEPTH_UNKNOWN)
+		{
+#if HWLOC_API_VERSION >= 0x00020000
+			global_mem = hwloc_get_root_obj(topology->hwtopology)->total_memory;
+#else
+			global_mem = hwloc_get_root_obj(topology->hwtopology)->memory.total_memory;
+#endif
+		}
+		else
+		{
+			char name[32];
+			hwloc_obj_t obj = hwloc_get_obj_by_depth(topology->hwtopology, depth_node, nodeid);
+#if HWLOC_API_VERSION >= 0x00020000
+			global_mem = obj->attr->numanode.local_memory;
+#else
+			global_mem = obj->memory.local_memory;
+#endif
+			snprintf(name, sizeof(name), "STARPU_LIMIT_CPU_NUMA_%d_MEM", obj->os_index);
+			limit = starpu_get_env_number(name);
+		}
+	}
+	else
+	{
+		/* Do not limit ourself to a single NUMA node */
+#if HWLOC_API_VERSION >= 0x00020000
+		global_mem = hwloc_get_root_obj(topology->hwtopology)->total_memory;
+#else
+		global_mem = hwloc_get_root_obj(topology->hwtopology)->memory.total_memory;
+#endif
+	}
+
+#else /* STARPU_HAVE_HWLOC */
+#ifdef STARPU_DEVEL
+#  warning TODO: use sysinfo when available to get global size
+#endif
+	global_mem = 0;
+#endif
+
+	if (limit == -1)
+		limit = starpu_get_env_number("STARPU_LIMIT_CPU_MEM");
+
+	if (limit < 0)
+		// No limit is defined, we return the global memory size
+		return global_mem;
+	else if (global_mem && (size_t)limit * 1024*1024 > global_mem)
+		// The requested limit is higher than what is available, we return the global memory size
+		return global_mem;
+	else
+		// We limit the memory
+		return limit*1024*1024;
+}
+
 //TODO : Check SIMGRID
 static void _starpu_init_numa_node(struct _starpu_machine_config *config)
 {

+ 0 - 64
src/drivers/cpu/driver_cpu.c

@@ -153,70 +153,6 @@ static int execute_job_on_cpu(struct _starpu_job *j, struct starpu_task *worker_
 	return 0;
 }
 
-size_t _starpu_cpu_get_global_mem_size(int nodeid STARPU_ATTRIBUTE_UNUSED, struct _starpu_machine_config *config STARPU_ATTRIBUTE_UNUSED)
-{
-	size_t global_mem;
-	starpu_ssize_t limit = -1;
-
-#if defined(STARPU_HAVE_HWLOC)
-	struct _starpu_machine_topology *topology = &config->topology;
-
-	if (starpu_get_env_number_default("STARPU_USE_NUMA", 0))
-	{
-		int depth_node = hwloc_get_type_depth(topology->hwtopology, HWLOC_OBJ_NUMANODE);
-
-		if (depth_node == HWLOC_TYPE_DEPTH_UNKNOWN)
-		{
-#if HWLOC_API_VERSION >= 0x00020000
-			global_mem = hwloc_get_root_obj(topology->hwtopology)->total_memory;
-#else
-			global_mem = hwloc_get_root_obj(topology->hwtopology)->memory.total_memory;
-#endif
-		}
-		else
-		{
-			char name[32];
-			hwloc_obj_t obj = hwloc_get_obj_by_depth(topology->hwtopology, depth_node, nodeid);
-#if HWLOC_API_VERSION >= 0x00020000
-			global_mem = obj->attr->numanode.local_memory;
-#else
-			global_mem = obj->memory.local_memory;
-#endif
-			snprintf(name, sizeof(name), "STARPU_LIMIT_CPU_NUMA_%d_MEM", obj->os_index);
-			limit = starpu_get_env_number(name);
-		}
-	}
-	else
-	{
-		/* Do not limit ourself to a single NUMA node */
-#if HWLOC_API_VERSION >= 0x00020000
-		global_mem = hwloc_get_root_obj(topology->hwtopology)->total_memory;
-#else
-		global_mem = hwloc_get_root_obj(topology->hwtopology)->memory.total_memory;
-#endif
-	}
-
-#else /* STARPU_HAVE_HWLOC */
-#ifdef STARPU_DEVEL
-#  warning TODO: use sysinfo when available to get global size
-#endif
-	global_mem = 0;
-#endif
-
-	if (limit == -1)
-		limit = starpu_get_env_number("STARPU_LIMIT_CPU_MEM");
-
-	if (limit < 0)
-		// No limit is defined, we return the global memory size
-		return global_mem;
-	else if (global_mem && (size_t)limit * 1024*1024 > global_mem)
-		// The requested limit is higher than what is available, we return the global memory size
-		return global_mem;
-	else
-		// We limit the memory
-		return limit*1024*1024;
-}
-
 int _starpu_cpu_driver_init(struct _starpu_worker *cpu_worker)
 {
 	int devid = cpu_worker->devid;

+ 0 - 1
src/drivers/cpu/driver_cpu.h

@@ -24,7 +24,6 @@
 #ifdef STARPU_USE_CPU
 
 extern struct _starpu_driver_ops _starpu_driver_cpu_ops;
-size_t _starpu_cpu_get_global_mem_size(int nodeid STARPU_ATTRIBUTE_UNUSED, struct _starpu_machine_config *config STARPU_ATTRIBUTE_UNUSED);
 void *_starpu_cpu_worker(void *);
 
 #endif /* !STARPU_USE_CPU */