Переглянути джерело

- If hwloc is available, we use it to detect the size of the memory: by
default, we allocate 75% of the ram for that experiment.
- Use BLOCK_SIZE to specify the size of the memory buffers

Cédric Augonnet 14 роки тому
батько
коміт
1819602acb
1 змінених файлів з 28 додано та 4 видалено
  1. 28 4
      tests/datawizard/reclaim.c

+ 28 - 4
tests/datawizard/reclaim.c

@@ -21,8 +21,25 @@
 
 #include <assert.h>
 #include <starpu.h>
+#ifdef STARPU_HAVE_HWLOC
+#include <hwloc.h>
+#endif
 
-static unsigned ntasks = 10000;
+#define BLOCK_SIZE	(64*1024*1024)
+
+static unsigned ntasks = 1000;
+
+#ifdef STARPU_HAVE_HWLOC
+static uint64_t get_total_memory_size(void)
+{
+	hwloc_topology_t hwtopology;
+	hwloc_topology_init(&hwtopology);
+	hwloc_topology_load(hwtopology);
+	hwloc_obj_t root = hwloc_get_root_obj(hwtopology);	
+
+	return root->memory.total_memory;
+}
+#endif
 
 static void dummy_func(void *descr[], __attribute__ ((unused)) void *_args)
 {
@@ -35,7 +52,7 @@ static starpu_codelet dummy_cl = {
 	.nbuffers = 3
 };
 
-/* Number of 1MB chunks */
+/* Number of chunks */
 static int mb = 256;
 
 int main(int argc, char **argv)
@@ -43,6 +60,13 @@ int main(int argc, char **argv)
 	int i;
 	int task;
 
+#ifdef STARPU_HAVE_HWLOC
+	/* We allocate 75% of the memory */
+	uint64_t total_size = get_total_memory_size();
+
+	mb = (int)((0.75 * total_size)/(BLOCK_SIZE));
+#endif
+
 	/* An optional argument indicates the number of MB to allocate */
 	if (argc > 1)
 		mb = atoi(argv[1]);
@@ -63,10 +87,10 @@ int main(int argc, char **argv)
 	/* Register mb buffers of 1MB */
 	for (i = 0; i < mb; i++)
 	{
-		host_ptr_array[i] = malloc(1024*1024);
+		host_ptr_array[i] = malloc(BLOCK_SIZE);
 		assert(host_ptr_array[i]);
 		starpu_variable_data_register(&handle_array[i], 0,
-			(uintptr_t)host_ptr_array[i], 1024*1024);
+			(uintptr_t)host_ptr_array[i], BLOCK_SIZE);
 		assert(handle_array[i]);
 	}