Browse Source

make sure usleep is available

Nathalie Furmento 6 years ago
parent
commit
892316275f
3 changed files with 16 additions and 2 deletions
  1. 1 0
      include/starpu_stdlib.h
  2. 13 0
      src/common/utils.c
  3. 2 2
      tests/perfmodels/regression_based.c

+ 1 - 0
include/starpu_stdlib.h

@@ -242,6 +242,7 @@ void starpu_memory_deallocate(unsigned node, size_t size);
 void starpu_memory_wait_available(unsigned node, size_t size);
 
 void starpu_sleep(float nb_sec);
+void starpu_usleep(float nb_micro_sec);
 
 /** @} */
 

+ 13 - 0
src/common/utils.c

@@ -549,6 +549,19 @@ void starpu_sleep(float nb_sec)
 #endif
 }
 
+void starpu_usleep(float nb_micro_sec)
+{
+#ifdef STARPU_SIMGRID
+	MSG_process_sleep(nb_sec / 1000000);
+#elif defined(STARPU_HAVE_WINDOWS)
+	Sleep(nb_micro_sec / 1000);
+#elif HAVE_UNISTD_H
+	usleep(nb_micro_sec);
+#else
+#error no implementation of usleep
+#endif
+}
+
 char *starpu_getenv(const char *str)
 {
 #ifndef STARPU_SIMGRID

+ 2 - 2
tests/perfmodels/regression_based.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2011,2012,2014                           Inria
  * Copyright (C) 2011-2016,2019                           Université de Bordeaux
- * Copyright (C) 2011-2017                                CNRS
+ * Copyright (C) 2011-2017, 2019                          CNRS
  * Copyright (C) 2011                                     Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -70,7 +70,7 @@ void memset_cpu(void *descr[], void *arg)
 	int *ptr = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
 	unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
 
-	usleep(10);
+	starpu_usleep(10);
 	memset(ptr, 42, n * sizeof(*ptr));
 }