Browse Source

fix build without lock_or_delegate

Samuel Thibault 10 years ago
parent
commit
3131740677

+ 40 - 8
src/core/dependencies/data_commute_concurrency.c

@@ -21,7 +21,7 @@
 #include <common/starpu_spinlock.h>
 #include <datawizard/sort_data_handles.h>
 
-//#define NO_LOCK_OR_DELEGATE
+#define NO_LOCK_OR_DELEGATE
 
 /*
  * This implements a solution for the dining philosophers problem (see
@@ -91,7 +91,7 @@
 /* A LockOrDelegate task list */
 struct LockOrDelegateListNode
 {
-	int (*func)(void*);
+	void (*func)(void*);
 	void* data;
 	struct LockOrDelegateListNode* next;
 };
@@ -111,7 +111,7 @@ static _Atomic struct LockOrDelegateListNode* dlListHead;
  * This function return 1 if the task (and maybe some others) has been done
  * by the calling thread and 0 otherwise (if the task has just been put in the list)
  */
-int _starpu_LockOrDelegatePostOrPerform(int (*func)(void*), void* data)
+static int _starpu_LockOrDelegatePostOrPerform(void (*func)(void*), void* data)
 {
 	/* Get our ticket */
 	int insertionPosition = atomic_load(&dlAtomicCounter);
@@ -181,7 +181,7 @@ static starpu_pthread_mutex_t dlWorkLock = STARPU_PTHREAD_MUTEX_INITIALIZER;
  * This function return 1 if the task (and maybe some others) has been done
  * by the calling thread and 0 otherwise (if the task has just been put in the list)
  */
-int _starpu_LockOrDelegatePostOrPerform(int (*func)(void*), void* data)
+static int _starpu_LockOrDelegatePostOrPerform(void (*func)(void*), void* data)
 {
 	/* We could avoid to allocate if we will be responsible but for simplicity
 	 * we always push the task in the list */
@@ -249,8 +249,16 @@ static unsigned remove_job_from_requester_list(struct _starpu_data_requester_lis
 }
 
 #ifndef NO_LOCK_OR_DELEGATE
+/* These are the arguments passed to _submit_job_enforce_commute_deps */
+struct starpu_enforce_commute_args
+{
+	struct _starpu_job *j;
+	unsigned buf;
+	unsigned nbuffers;
+};
 
-int _starpu_submit_job_enforce_commute_deps(void* inData)
+static void ___starpu_submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers);
+static void __starpu_submit_job_enforce_commute_deps(void* inData)
 {
 	struct starpu_enforce_commute_args* args = (struct starpu_enforce_commute_args*)inData;
 	struct _starpu_job *j = args->j;
@@ -260,8 +268,23 @@ int _starpu_submit_job_enforce_commute_deps(void* inData)
 	free(args);
 	args = NULL;
 	inData = NULL;
+	___starpu_submit_job_enforce_commute_deps(j, buf, nbuffers);
+}
+
+void _starpu_submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers)
+{
+	struct starpu_enforce_commute_args* args = (struct starpu_enforce_commute_args*)malloc(sizeof(struct starpu_enforce_commute_args));
+	args->j = j;
+	args->buf = buf;
+	args->nbuffers = nbuffers;
+	/* The function will delete args */
+	_starpu_LockOrDelegatePostOrPerform(&__starpu_submit_job_enforce_commute_deps, args);
+}
+
+static void ___starpu_submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers)
+{
 #else // NO_LOCK_OR_DELEGATE
-int _submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers)
+void _starpu_submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers)
 {
 	STARPU_PTHREAD_MUTEX_LOCK(&commute_global_mutex);
 #endif
@@ -354,11 +377,20 @@ int _submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsign
 }
 
 #ifndef NO_LOCK_OR_DELEGATE
-int _starpu_notify_commute_dependencies(void* inData)
+void ___starpu_notify_commute_dependencies(starpu_data_handle_t handle);
+void __starpu_notify_commute_dependencies(void* inData)
 {
 	starpu_data_handle_t handle = (starpu_data_handle_t)inData;
+	___starpu_notify_commute_dependencies(handle);
+}
+void _starpu_notify_commute_dependencies(starpu_data_handle_t handle)
+{
+	_starpu_LockOrDelegatePostOrPerform(&__starpu_notify_commute_dependencies, handle);
+}
+void ___starpu_notify_commute_dependencies(starpu_data_handle_t handle)
+{
 #else // NO_LOCK_OR_DELEGATE
-int _starpu_notify_commute_dependencies(starpu_data_handle_t handle)
+void _starpu_notify_commute_dependencies(starpu_data_handle_t handle)
 {
 	STARPU_PTHREAD_MUTEX_LOCK(&commute_global_mutex);
 #endif

+ 0 - 13
src/core/dependencies/data_concurrency.c

@@ -288,16 +288,7 @@ static unsigned _submit_job_enforce_data_deps(struct _starpu_job *j, unsigned st
 	/* We arrive on the commutes */
 	if(buf != nbuffers)
 	{
-#ifndef NO_LOCK_OR_DELEGATE
-		struct starpu_enforce_commute_args* args = (struct starpu_enforce_commute_args*)malloc(sizeof(struct starpu_enforce_commute_args));
-		args->j = j;
-		args->buf = buf;
-		args->nbuffers = nbuffers;
-		/* The function will delete args */
-		_starpu_LockOrDelegatePostOrPerform(&_starpu_submit_job_enforce_commute_deps, args);
-#else // NO_LOCK_OR_DELEGATE
 		_starpu_submit_job_enforce_commute_deps(j, buf, nbuffers);
-#endif
 		return 1;
 	}
 	// WIP_COMMUTE End
@@ -457,11 +448,7 @@ int _starpu_notify_data_dependencies(starpu_data_handle_t handle)
 		 * but we alloc fist the global mutex and than the handles mutex
 		 */
 		_starpu_spin_unlock(&handle->header_lock);
-#ifndef NO_LOCK_OR_DELEGATE
-		_starpu_LockOrDelegatePostOrPerform(&_starpu_notify_commute_dependencies, handle);
-#else // NO_LOCK_OR_DELEGATE
 		_starpu_notify_commute_dependencies(handle);
-#endif
 		/* We need to lock when returning 0 */
 		return 1;
 	}

+ 2 - 12
src/core/dependencies/data_concurrency.h

@@ -22,20 +22,10 @@
 #include <core/jobs.h>
 
 unsigned _starpu_submit_job_enforce_data_deps(struct _starpu_job *j);
-int _starpu_submit_job_enforce_commute_deps(void* inData);
-
-/* These are the arguments passed to _submit_job_enforce_commute_deps */
-struct starpu_enforce_commute_args
-{
-	struct _starpu_job *j;
-	unsigned buf;
-	unsigned nbuffers;
-};
-
-int _starpu_LockOrDelegatePostOrPerform(int (*func)(void*), void* data);
+void _starpu_submit_job_enforce_commute_deps(struct _starpu_job *j, unsigned buf, unsigned nbuffers);
 
 int _starpu_notify_data_dependencies(starpu_data_handle_t handle);
-int _starpu_notify_commute_dependencies(void* inData);
+void _starpu_notify_commute_dependencies(starpu_data_handle_t handle);
 
 unsigned _starpu_attempt_to_submit_data_request_from_apps(starpu_data_handle_t handle,
 							  enum starpu_data_access_mode mode,