Quellcode durchsuchen

fix support for more that 4G tasks

Samuel Thibault vor 9 Jahren
Ursprung
Commit
54f8793eb2
4 geänderte Dateien mit 59 neuen und 12 gelöschten Zeilen
  1. 50 3
      include/starpu_util.h
  2. 3 3
      src/core/jobs.c
  3. 4 4
      src/datawizard/copy_driver.c
  4. 2 2
      src/datawizard/data_request.h

+ 50 - 3
include/starpu_util.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010-2015  Université de Bordeaux
+ * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -165,6 +165,26 @@ static __starpu_inline unsigned starpu_xchg(unsigned *ptr, unsigned next)
 	return next;
 	return next;
 }
 }
 #define STARPU_HAVE_XCHG
 #define STARPU_HAVE_XCHG
+
+#if defined(__i386__)
+#define starpu_cmpxchgl starpu_cmpxchg
+#define starpu_xchgl starpu_xchg
+#define STARPU_HAVE_XCHGL
+#endif
+#if defined(__x86_64__)
+static __starpu_inline unsigned long starpu_cmpxchgl(unsigned long *ptr, unsigned long old, unsigned long next)
+{
+	__asm__ __volatile__("lock cmpxchgq %2,%1": "+a" (old), "+m" (*ptr) : "q" (next) : "memory");
+	return old;
+}
+static __starpu_inline unsigned long starpu_xchgl(unsigned long *ptr, unsigned long next)
+{
+	/* Note: xchg is always locked already */
+	__asm__ __volatile__("xchgq %1,%0": "+m" (*ptr), "+q" (next) : : "memory");
+	return next;
+}
+#define STARPU_HAVE_XCHGL
+#endif
 #endif
 #endif
 
 
 #define STARPU_ATOMIC_SOMETHING(name,expr) \
 #define STARPU_ATOMIC_SOMETHING(name,expr) \
@@ -180,20 +200,47 @@ static __starpu_inline unsigned starpu_atomic_##name(unsigned *ptr, unsigned val
 	}; \
 	}; \
 	return expr; \
 	return expr; \
 }
 }
+#define STARPU_ATOMIC_SOMETHINGL(name,expr) \
+static __starpu_inline unsigned long starpu_atomic_##name##l(unsigned long *ptr, unsigned long value) \
+{ \
+	unsigned long old, next; \
+	while (1) \
+	{ \
+		old = *ptr; \
+		next = expr; \
+		if (starpu_cmpxchg(ptr, old, next) == old) \
+			break; \
+	}; \
+	return expr; \
+}
 
 
 #ifdef STARPU_HAVE_SYNC_FETCH_AND_ADD
 #ifdef STARPU_HAVE_SYNC_FETCH_AND_ADD
 #define STARPU_ATOMIC_ADD(ptr, value)  (__sync_fetch_and_add ((ptr), (value)) + (value))
 #define STARPU_ATOMIC_ADD(ptr, value)  (__sync_fetch_and_add ((ptr), (value)) + (value))
-#elif defined(STARPU_HAVE_XCHG)
+#define STARPU_ATOMIC_ADDL(ptr, value)  (__sync_fetch_and_add ((ptr), (value)) + (value))
+#else
+#if defined(STARPU_HAVE_XCHG)
 STARPU_ATOMIC_SOMETHING(add, old + value)
 STARPU_ATOMIC_SOMETHING(add, old + value)
 #define STARPU_ATOMIC_ADD(ptr, value) starpu_atomic_add(ptr, value)
 #define STARPU_ATOMIC_ADD(ptr, value) starpu_atomic_add(ptr, value)
 #endif
 #endif
+#if defined(STARPU_HAVE_XCHGL)
+STARPU_ATOMIC_SOMETHINGL(add, old + value)
+#define STARPU_ATOMIC_ADDL(ptr, value) starpu_atomic_addl(ptr, value)
+#endif
+#endif
 
 
 #ifdef STARPU_HAVE_SYNC_FETCH_AND_OR
 #ifdef STARPU_HAVE_SYNC_FETCH_AND_OR
 #define STARPU_ATOMIC_OR(ptr, value)  (__sync_fetch_and_or ((ptr), (value)))
 #define STARPU_ATOMIC_OR(ptr, value)  (__sync_fetch_and_or ((ptr), (value)))
-#elif defined(STARPU_HAVE_XCHG)
+#define STARPU_ATOMIC_ORL(ptr, value)  (__sync_fetch_and_or ((ptr), (value)))
+#else
+#if defined(STARPU_HAVE_XCHG)
 STARPU_ATOMIC_SOMETHING(or, old | value)
 STARPU_ATOMIC_SOMETHING(or, old | value)
 #define STARPU_ATOMIC_OR(ptr, value) starpu_atomic_or(ptr, value)
 #define STARPU_ATOMIC_OR(ptr, value) starpu_atomic_or(ptr, value)
 #endif
 #endif
+#if defined(STARPU_HAVE_XCHGL)
+STARPU_ATOMIC_SOMETHINGL(or, old | value)
+#define STARPU_ATOMIC_ORL(ptr, value) starpu_atomic_orl(ptr, value)
+#endif
+#endif
 
 
 #ifdef STARPU_HAVE_SYNC_BOOL_COMPARE_AND_SWAP
 #ifdef STARPU_HAVE_SYNC_BOOL_COMPARE_AND_SWAP
 #define STARPU_BOOL_COMPARE_AND_SWAP(ptr, old, value)  (__sync_bool_compare_and_swap ((ptr), (old), (value)))
 #define STARPU_BOOL_COMPARE_AND_SWAP(ptr, old, value)  (__sync_bool_compare_and_swap ((ptr), (old), (value)))

+ 3 - 3
src/core/jobs.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2009-2015  Université de Bordeaux
+ * Copyright (C) 2009-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2011, 2014  INRIA
  * Copyright (C) 2011, 2014  INRIA
@@ -31,7 +31,7 @@
 #include <core/debug.h>
 #include <core/debug.h>
 
 
 /* we need to identify each task to generate the DAG. */
 /* we need to identify each task to generate the DAG. */
-static unsigned job_cnt = 0;
+static unsigned long job_cnt = 0;
 
 
 #ifdef STARPU_DEBUG
 #ifdef STARPU_DEBUG
 /* List of all jobs, for debugging */
 /* List of all jobs, for debugging */
@@ -74,7 +74,7 @@ struct _starpu_job* STARPU_ATTRIBUTE_MALLOC _starpu_job_create(struct starpu_tas
 			)
 			)
 #endif
 #endif
 	{
 	{
-		job->job_id = STARPU_ATOMIC_ADD(&job_cnt, 1);
+		job->job_id = STARPU_ATOMIC_ADDL(&job_cnt, 1);
 #ifdef HAVE_AYUDAME_H
 #ifdef HAVE_AYUDAME_H
 		if (AYU_event)
 		if (AYU_event)
 		{
 		{

+ 4 - 4
src/datawizard/copy_driver.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010-2015  Université de Bordeaux
+ * Copyright (C) 2010-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013  CNRS
  * Copyright (C) 2010, 2011, 2013  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -98,7 +98,7 @@ void starpu_wake_all_blocked_workers(void)
 /* we need to identify each communication so that we can match the beginning
 /* we need to identify each communication so that we can match the beginning
  * and the end of a communication in the trace, so we use a unique identifier
  * and the end of a communication in the trace, so we use a unique identifier
  * per communication */
  * per communication */
-static unsigned communication_cnt = 0;
+static unsigned long communication_cnt = 0;
 #endif
 #endif
 
 
 static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
 static int copy_data_1_to_1_generic(starpu_data_handle_t handle,
@@ -492,7 +492,7 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 	}
 	}
 
 
 	int ret_alloc, ret_copy;
 	int ret_alloc, ret_copy;
-	unsigned STARPU_ATTRIBUTE_UNUSED com_id = 0;
+	unsigned long STARPU_ATTRIBUTE_UNUSED com_id = 0;
 
 
 	unsigned src_node = src_replicate->memory_node;
 	unsigned src_node = src_replicate->memory_node;
 	unsigned dst_node = dst_replicate->memory_node;
 	unsigned dst_node = dst_replicate->memory_node;
@@ -520,7 +520,7 @@ int STARPU_ATTRIBUTE_WARN_UNUSED_RESULT _starpu_driver_copy_data_1_to_1(starpu_d
 		_starpu_bus_update_profiling_info((int)src_node, (int)dst_node, size);
 		_starpu_bus_update_profiling_info((int)src_node, (int)dst_node, size);
 
 
 #ifdef STARPU_USE_FXT
 #ifdef STARPU_USE_FXT
-		com_id = STARPU_ATOMIC_ADD(&communication_cnt, 1);
+		com_id = STARPU_ATOMIC_ADDL(&communication_cnt, 1);
 
 
 		if (req)
 		if (req)
 			req->com_id = com_id;
 			req->com_id = com_id;

+ 2 - 2
src/datawizard/data_request.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2009-2010, 2013-2015  Université de Bordeaux
+ * Copyright (C) 2009-2010, 2013-2016  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013  CNRS
  * Copyright (C) 2010, 2011, 2013  CNRS
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -93,7 +93,7 @@ LIST_TYPE(_starpu_data_request,
 
 
 	struct _starpu_callback_list *callbacks;
 	struct _starpu_callback_list *callbacks;
 
 
-	unsigned com_id;
+	unsigned long com_id;
 )
 )
 PRIO_LIST_TYPE(_starpu_data_request, prio)
 PRIO_LIST_TYPE(_starpu_data_request, prio)