Ver código fonte

STARPU_DATA_ACQUIRE_CB is defined only when using a GCC compiler, as nested functions are only supported by this compiler

Nathalie Furmento 14 anos atrás
pai
commit
ab02f72806
3 arquivos alterados com 19 adições e 3 exclusões
  1. 3 1
      doc/starpu.texi
  2. 6 1
      include/starpu_data.h
  3. 10 1
      tests/datawizard/acquire_cb_insert.c

+ 3 - 1
doc/starpu.texi

@@ -1458,7 +1458,9 @@ acquiring data @code{i} for the main application, and will execute the code
 given as third parameter when it is acquired. In other words, as soon as the
 given as third parameter when it is acquired. In other words, as soon as the
 value of @code{i} computed by the @code{which_index} codelet can be read, the
 value of @code{i} computed by the @code{which_index} codelet can be read, the
 portion of code passed as third parameter of @code{STARPU_DATA_ACQUIRE_CB} will
 portion of code passed as third parameter of @code{STARPU_DATA_ACQUIRE_CB} will
-be executed, and is allowed to read from @code{i} to use it e.g. as an index.
+be executed, and is allowed to read from @code{i} to use it e.g. as an
+index. Note that this macro is only avaible when compiling StarPU with
+the compiler @code{gcc}.
 
 
 @node Debugging
 @node Debugging
 @section Debugging
 @section Debugging

+ 6 - 1
include/starpu_data.h

@@ -60,13 +60,18 @@ void starpu_data_advise_as_important(starpu_data_handle handle, unsigned is_impo
 int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode);
 int starpu_data_acquire(starpu_data_handle handle, starpu_access_mode mode);
 int starpu_data_acquire_cb(starpu_data_handle handle,
 int starpu_data_acquire_cb(starpu_data_handle handle,
 			starpu_access_mode mode, void (*callback)(void *), void *arg);
 			starpu_access_mode mode, void (*callback)(void *), void *arg);
-#define STARPU_DATA_ACQUIRE_CB(handle, mode, code) do { \
+#ifdef __GCC__
+#  define STARPU_DATA_ACQUIRE_CB(handle, mode, code) do { \
 	void callback(void *arg) { \
 	void callback(void *arg) { \
 		code; \
 		code; \
 		starpu_data_release(handle); \
 		starpu_data_release(handle); \
 	} \
 	} \
 	starpu_data_acquire_cb(handle, mode, callback, NULL); \
 	starpu_data_acquire_cb(handle, mode, callback, NULL); \
 } while(0)
 } while(0)
+#else
+#  define STARPU_DATA_ACQUIRE_CB(handle, mode, node) assert(0)
+#endif
+
 void starpu_data_release(starpu_data_handle handle);
 void starpu_data_release(starpu_data_handle handle);
 
 
 int starpu_malloc(void **A, size_t dim);
 int starpu_malloc(void **A, size_t dim);

+ 10 - 1
tests/datawizard/acquire_cb_insert.c

@@ -52,12 +52,17 @@ starpu_codelet work = {
 };
 };
 
 
 static int x;
 static int x;
+static starpu_data_handle x_handle, f_handle;
+
+void callback(void *arg) {
+	starpu_insert_task(&work, STARPU_W, starpu_data_get_sub_data(f_handle, 1, x), 0);
+	starpu_data_release(x_handle);
+}
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
         int i, ret;
         int i, ret;
 	float *f;
 	float *f;
-	starpu_data_handle x_handle, f_handle;
 
 
 	starpu_init(NULL);
 	starpu_init(NULL);
 
 
@@ -81,11 +86,15 @@ int main(int argc, char **argv)
 	if (ret == -ENODEV) goto enodev;
 	if (ret == -ENODEV) goto enodev;
 
 
 	/* And submit the corresponding task */
 	/* And submit the corresponding task */
+#ifdef __GCC__
 	STARPU_DATA_ACQUIRE_CB(
 	STARPU_DATA_ACQUIRE_CB(
 			x_handle,
 			x_handle,
 			STARPU_R,
 			STARPU_R,
 			starpu_insert_task(&work, STARPU_W, starpu_data_get_sub_data(f_handle, 1, x), 0)
 			starpu_insert_task(&work, STARPU_W, starpu_data_get_sub_data(f_handle, 1, x), 0)
 			);
 			);
+#else
+	starpu_data_acquire_cb(x_handle, STARPU_W, callback, NULL);
+#endif
 
 
 	starpu_task_wait_for_all();
 	starpu_task_wait_for_all();
 	starpu_data_unpartition(f_handle, 0);
 	starpu_data_unpartition(f_handle, 0);