Explorar o código

Better use an inline and macro to get best performance and file/line

Samuel Thibault %!s(int64=9) %!d(string=hai) anos
pai
achega
ff2c06f79a
Modificáronse 2 ficheiros con 7 adicións e 8 borrados
  1. 0 7
      src/core/workers.c
  2. 7 1
      src/core/workers.h

+ 0 - 7
src/core/workers.c

@@ -1686,13 +1686,6 @@ int starpu_worker_get_id(void)
 }
 #define starpu_worker_get_id _starpu_worker_get_id
 
-unsigned _starpu_worker_get_id_check(void)
-{
-	int id = starpu_worker_get_id();
-	STARPU_ASSERT_MSG(id>=0, "Cannot be called from outside a worker\n");
-	return id;
-}
-
 int starpu_combined_worker_get_id(void)
 {
 	struct _starpu_worker *worker;

+ 7 - 1
src/core/workers.h

@@ -559,6 +559,12 @@ static inline int _starpu_worker_get_id(void)
 #define starpu_worker_get_id _starpu_worker_get_id
 
 /* Similar behaviour to starpu_worker_get_id() but fails when called from outside a worker */
-unsigned _starpu_worker_get_id_check(void);
+static inline unsigned __starpu_worker_get_id_check(char *f, int l)
+{
+	int id = starpu_worker_get_id();
+	STARPU_ASSERT_MSG(id>=0, "%s:%u Cannot be called from outside a worker\n", f, l);
+	return id;
+}
+#define _starpu_worker_get_id_check() __starpu_worker_get_id_check(__FILE__, __LINE__)
 
 #endif // __WORKERS_H__