Przeglądaj źródła

memory: new functions starpu_memory_get_total_all_nodes() and starpu_memory_get_available_all_nodes()

Nathalie Furmento 8 lat temu
rodzic
commit
347ce32167

+ 10 - 0
doc/doxygen/chapters/api/standard_memory_library.doxy

@@ -103,12 +103,22 @@ If a memory limit is defined on the given node (see Section
 \ref HowToLimitMemoryPerNode), return the amount of total memory
 \ref HowToLimitMemoryPerNode), return the amount of total memory
 on the node. Otherwise return -1.
 on the node. Otherwise return -1.
 
 
+\fn ssize_t starpu_memory_get_total_all_nodes()
+\ingroup API_Standard_Memory_Library
+return the amount of total memory on all memory nodes for whose a memory limit
+is defined (see Section \ref HowToLimitMemoryPerNode).
+
 \fn ssize_t starpu_memory_get_available(unsigned node)
 \fn ssize_t starpu_memory_get_available(unsigned node)
 \ingroup API_Standard_Memory_Library
 \ingroup API_Standard_Memory_Library
 If a memory limit is defined on the given node (see Section
 If a memory limit is defined on the given node (see Section
 \ref HowToLimitMemoryPerNode), return the amount of available memory
 \ref HowToLimitMemoryPerNode), return the amount of available memory
 on the node. Otherwise return -1.
 on the node. Otherwise return -1.
 
 
+\fn ssize_t starpu_memory_get_available_all_nodes()
+\ingroup API_Standard_Memory_Library
+return the amount of available memory on all memory nodes for whose a memory limit
+is defined (see Section \ref HowToLimitMemoryPerNode).
+
 \fn int starpu_memory_allocate(unsigned node, size_t size, int flags)
 \fn int starpu_memory_allocate(unsigned node, size_t size, int flags)
 \ingroup API_Standard_Memory_Library
 \ingroup API_Standard_Memory_Library
 If a memory limit is defined on the given node (see Section
 If a memory limit is defined on the given node (see Section

+ 4 - 1
include/starpu_stdlib.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
  * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010-2016  Université de Bordeaux
- * Copyright (C) 2010, 2011, 2012, 2013  CNRS
+ * Copyright (C) 2010, 2011, 2012, 2013, 2016  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
  * it under the terms of the GNU Lesser General Public License as published by
@@ -47,6 +47,9 @@ int starpu_memory_unpin(void *addr, size_t size);
 
 
 starpu_ssize_t starpu_memory_get_total(unsigned node);
 starpu_ssize_t starpu_memory_get_total(unsigned node);
 starpu_ssize_t starpu_memory_get_available(unsigned node);
 starpu_ssize_t starpu_memory_get_available(unsigned node);
+starpu_ssize_t starpu_memory_get_total_all_nodes();
+starpu_ssize_t starpu_memory_get_available_all_nodes();
+
 void starpu_memory_wait_available(unsigned node, size_t size);
 void starpu_memory_wait_available(unsigned node, size_t size);
 
 
 /**
 /**

+ 29 - 1
src/datawizard/memory_manager.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2012-2013, 2015  CNRS
+ * Copyright (C) 2012-2013, 2015, 2016  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
  * it under the terms of the GNU Lesser General Public License as published by
@@ -133,6 +133,20 @@ starpu_ssize_t starpu_memory_get_total(unsigned node)
 		return global_size[node];
 		return global_size[node];
 }
 }
 
 
+starpu_ssize_t starpu_memory_get_total_all_nodes()
+{
+	unsigned memnodes, i;
+	memnodes = starpu_memory_nodes_get_count();
+	starpu_ssize_t total = 0;
+	for(i=0 ; i<memnodes ; i++)
+	{
+		starpu_ssize_t node = starpu_memory_get_total(i);
+		if (node != -1)
+			total += node;
+	}
+	return total;
+}
+
 starpu_ssize_t starpu_memory_get_available(unsigned node)
 starpu_ssize_t starpu_memory_get_available(unsigned node)
 {
 {
 	starpu_ssize_t ret;
 	starpu_ssize_t ret;
@@ -143,6 +157,20 @@ starpu_ssize_t starpu_memory_get_available(unsigned node)
 	return ret;
 	return ret;
 }
 }
 
 
+starpu_ssize_t starpu_memory_get_available_all_nodes()
+{
+	unsigned memnodes, i;
+	memnodes = starpu_memory_nodes_get_count();
+	starpu_ssize_t avail = 0;
+	for(i=0 ; i<memnodes ; i++)
+	{
+		starpu_ssize_t node = starpu_memory_get_available(i);
+		if (node != -1)
+			avail += node;
+	}
+	return avail;
+}
+
 void starpu_memory_wait_available(unsigned node, size_t size)
 void starpu_memory_wait_available(unsigned node, size_t size)
 {
 {
 	STARPU_PTHREAD_MUTEX_LOCK(&lock_nodes[node]);
 	STARPU_PTHREAD_MUTEX_LOCK(&lock_nodes[node]);