Browse Source

Automatically disable memory pinning when running in valgrind

Samuel Thibault 11 years ago
parent
commit
a9b47f084e
3 changed files with 7 additions and 9 deletions
  1. 2 7
      doc/doxygen/chapters/11debugging_tools.doxy
  2. 4 1
      src/common/utils.h
  3. 1 1
      src/datawizard/malloc.c

+ 2 - 7
doc/doxygen/chapters/11debugging_tools.doxy

@@ -20,13 +20,8 @@ Some gdb helpers are also provided to show the whole StarPU state:
 \endverbatim
 
 Valgrind can be used on StarPU: valgrind.h just needs to be found at ./configure
-time, to tell valgrind about some known false positives. When working with GPUs,
-memory pinning should be disabled with
-
-export STARPU_DISABLE_PINNING=1
-
-otherwise valgrind will not properly catch errors about data allocated through
-starpu_malloc and friends.
+time, to tell valgrind about some known false positives and disable host memory
+pinning.
 
 The Temanejo task debugger can also be used, see \ref UsingTheTemanejoTaskDebugger.
 

+ 4 - 1
src/common/utils.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2013  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012-2014  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012, 2013  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -51,6 +51,9 @@
 #ifndef VALGRIND_HG_ENABLE_CHECKING
 #define VALGRIND_HG_ENABLE_CHECKING(start, len) ((void)0)
 #endif
+#ifndef RUNNING_ON_VALGRIND
+#define RUNNING_ON_VALGRIND 0
+#endif
 #define STARPU_HG_DISABLE_CHECKING(variable) VALGRIND_HG_DISABLE_CHECKING(&(variable), sizeof(variable))
 #define STARPU_HG_ENABLE_CHECKING(variable)  VALGRIND_HG_ENABLE_CHECKING(&(variable), sizeof(variable))
 

+ 1 - 1
src/datawizard/malloc.c

@@ -109,7 +109,7 @@ int starpu_malloc_flags(void **A, size_t dim, int flags)
 		}
 	}
 
-	if (flags & STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0)
+	if (flags & STARPU_MALLOC_PINNED && starpu_get_env_number("STARPU_DISABLE_PINNING") <= 0 && RUNNING_ON_VALGRIND == 0)
 	{
 #ifdef STARPU_SIMGRID
 		/* FIXME: CUDA seems to be taking 650µs every 1MiB.