Prechádzať zdrojové kódy

Fix compilation on Mac OS X (tested without OpenCL on a 64bit imac)

Cédric Augonnet 14 rokov pred
rodič
commit
d56a66ebba

+ 13 - 6
configure.ac

@@ -54,9 +54,13 @@ esac
 AM_CONDITIONAL([STARPU_HAVE_WINDOWS], [test "x$starpu_windows" = "xyes"])
 
 # on Darwin, GCC targets i386 by default, so we don't have atomic ops
-case "$target" in
-i386-*darwin*) CFLAGS+=" -march=i686 " ;;
-esac
+AC_CHECK_SIZEOF([void *])
+if test x$SIZEOF_VOID_P = x4; then
+	case "$target" in
+	i386-*darwin*) CFLAGS+=" -march=i686 " ;;
+	esac
+fi
+
 
 
 # This will be useful for program which use CUDA (and .cubin files) which need
@@ -282,9 +286,10 @@ if test x$enable_cuda = xyes; then
 	AC_DEFINE(STARPU_USE_CUDA, [1], [CUDA support is activated])
 
 	# On Darwin, the libstdc++ dependency is not automatically added by nvcc
-	case "$target" in
-		*-*darwin*) AC_HAVE_LIBRARY([stdc++], [STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lstdc++"]) ;;
-	esac
+#	case "$target" in
+#		*-*darwin*) AC_HAVE_LIBRARY([stdc++], []) ;;
+#		#*-*darwin*) AC_HAVE_LIBRARY([stdc++], [STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lstdc++"]) ;;
+#	esac
 	STARPU_CUDA_LDFLAGS="$STARPU_CUDA_LDFLAGS -lcuda"
 
         AC_SUBST(STARPU_CUDA_LDFLAGS)
@@ -297,6 +302,8 @@ if test x$enable_cuda = xyes; then
 		AC_SUBST(NVCCFLAGS)
 	fi
 
+	NVCCFLAGS=$"${NVCCFLAGS} -m64"
+
 	AC_PATH_PROG([NVCC], [nvcc], [nvcc], [$cuda_dir/bin:$PATH:/usr/local/bin:/usr/bin:/bin], [AC_MSG_WARN(Cannot find nvcc.)])
 fi
 

+ 2 - 2
doc/starpu.texi

@@ -1951,7 +1951,7 @@ Disable the use of OpenCL, even if the SDK is detected.
 @table @asis
 @item @emph{Description}:
 Specify the location of the OpenCL SDK. This directory should notably contain
-@code{include/CL/cl.h}.
+@code{include/CL/cl.h} (or @code{include/OpenCL/cl.h} on Mac OS).
 @end table
 
 @node --with-opencl-include-dir
@@ -1959,7 +1959,7 @@ Specify the location of the OpenCL SDK. This directory should notably contain
 @table @asis
 @item @emph{Description}:
 Specify the location of OpenCL headers. This directory should notably contain
-@code{CL/cl.h}. This defaults to
+@code{CL/cl.h} (or @code{OpenCL/cl.h} on Mac OS). This defaults to
 @code{/include} appended to the value given to @code{--with-opencl-dir}.
 
 @end table

+ 1 - 0
examples/cholesky/cholesky.h

@@ -18,6 +18,7 @@
 #ifndef __DW_CHOLESKY_H__
 #define __DW_CHOLESKY_H__
 
+#include <limits.h>
 #include <string.h>
 #include <math.h>
 #include <sys/time.h>

+ 0 - 1
examples/incrementer/incrementer_kernels_opencl.c

@@ -17,7 +17,6 @@
 
 #include <starpu.h>
 #include <starpu_opencl.h>
-#include <CL/cl.h>
 
 extern struct starpu_opencl_program opencl_program;
 void opencl_codelet(void *descr[], void *_args)

+ 1 - 0
examples/mult/xgemm.c

@@ -16,6 +16,7 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
+#include <limits.h>
 #include <string.h>
 #include <math.h>
 #include <sys/types.h>

+ 4 - 0
include/starpu_opencl.h

@@ -19,7 +19,11 @@
 #define __STARPU_OPENCL_H__
 
 #ifdef STARPU_USE_OPENCL
+#ifdef __APPLE__
+#include <OpenCL/cl.h>
+#else
 #include <CL/cl.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {

+ 4 - 4
src/core/combined_workers.c

@@ -113,9 +113,9 @@ int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
 
 	/* Note that we maintain both the cpu_set and the hwloc_cpu_set so that
 	 * the application is not forced to use hwloc when it is available. */
-#ifndef STARPU_HAVE_WINDOWS
+#if !defined(STARPU_HAVE_WINDOWS) && !defined(__APPLE__)
 	CPU_ZERO(&combined_worker->cpu_set);
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* !STARPU_HAVE_WINDOWS && !Ã__APPLE__ */
 
 #ifdef STARPU_HAVE_HWLOC
 	combined_worker->hwloc_cpu_set = hwloc_bitmap_alloc();
@@ -124,7 +124,7 @@ int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
 	for (i = 0; i < nworkers; i++)
 	{
 		int id = workerid_array[i];
-#ifndef STARPU_HAVE_WINDOWS
+#if !defined(STARPU_HAVE_WINDOWS) && !defined(__APPLE__)
 #ifdef CPU_OR
 		CPU_OR(&combined_worker->cpu_set,
 			&combined_worker->cpu_set,
@@ -136,7 +136,7 @@ int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
 				CPU_SET(j, &combined_worker->cpu_set);
 		}
 #endif
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* !STARPU_HAVE_WINDOWS && !__APPLE__*/
 
 #ifdef STARPU_HAVE_HWLOC
 		hwloc_bitmap_or(combined_worker->hwloc_cpu_set,

+ 2 - 2
src/core/topology.c

@@ -722,13 +722,13 @@ static void _starpu_init_workers_binding(struct starpu_machine_config_s *config)
 
 		workerarg->memory_node = memory_node;
 
-#ifndef STARPU_HAVE_WINDOWS
+#if !defined(STARPU_HAVE_WINDOWS) && !defined(__APPLE__)
 		/* Save the initial cpuset */
 		CPU_ZERO(&workerarg->initial_cpu_set);
 		CPU_SET(workerarg->bindid, &workerarg->initial_cpu_set);
 		CPU_ZERO(&workerarg->current_cpu_set);
 		CPU_SET(workerarg->bindid, &workerarg->current_cpu_set);
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* !STARPU_HAVE_WINDOWS && !__APPLE__ */
 
 #ifdef STARPU_HAVE_HWLOC
 		/* Clear the cpu set and set the cpu */

+ 4 - 4
src/core/workers.h

@@ -78,10 +78,10 @@ struct starpu_worker_s {
 	starpu_worker_status status; /* what is the worker doing now ? (eg. CALLBACK) */
 	char name[32];
 
-#ifndef STARPU_HAVE_WINDOWS
+#if !defined(STARPU_HAVE_WINDOWS) && !defined(__APPLE__)
 	cpu_set_t initial_cpu_set;
 	cpu_set_t current_cpu_set;
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* !STARPU_HAVE_WINDOWS && ! __APPLE__ */
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_cpuset_t initial_hwloc_cpu_set;
 	hwloc_cpuset_t current_hwloc_cpu_set;
@@ -95,9 +95,9 @@ struct starpu_combined_worker_s {
 	unsigned memory_node; /* which memory node is associated that worker to ? */
 	int combined_workerid[STARPU_NMAXWORKERS];
 
-#ifndef STARPU_HAVE_WINDOWS
+#if !defined(STARPU_HAVE_WINDOWS) && !defined(__APPLE__)
 	cpu_set_t cpu_set;
-#endif /* STARPU_HAVE_WINDOWS */
+#endif /* !STARPU_HAVE_WINDOWS && !__APPLE__*/
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_cpuset_t hwloc_cpu_set;
 #endif

+ 1 - 1
src/datawizard/copy_driver.h

@@ -30,7 +30,7 @@
 #endif
 
 #ifdef STARPU_USE_OPENCL
-#include <CL/cl.h>
+#include <starpu_opencl.h>
 #endif
 
 struct starpu_data_request_s;

+ 4 - 0
src/drivers/opencl/driver_opencl.h

@@ -24,7 +24,11 @@
 
 #ifdef STARPU_USE_OPENCL
 
+#ifdef __APPLE__
+#include <OpenCL/cl.h>
+#else
 #include <CL/cl.h>
+#endif
 
 extern
 int _starpu_opencl_init_context(int devid);

+ 2 - 2
tests/datawizard/increment_redux.c

@@ -18,10 +18,10 @@
 #include <starpu.h>
 
 #ifdef STARPU_USE_CUDA
-#include <cuda.h>
+#include <starpu_cuda.h>
 #endif
 #ifdef STARPU_USE_OPENCL
-#include <CL/cl.h>
+#include <starpu_opencl.h>
 #endif
 
 

+ 2 - 2
tests/datawizard/increment_redux_v2.c

@@ -17,10 +17,10 @@
 #include <starpu.h>
 
 #ifdef STARPU_USE_CUDA
-#include <cuda.h>
+#include <starpu_cuda.h>
 #endif
 #ifdef STARPU_USE_OPENCL
-#include <CL/cl.h>
+#include <starpu_opencl.h>
 #endif
 
 

+ 1 - 1
tests/datawizard/manual_reduction.c

@@ -19,7 +19,7 @@
 #include <cuda.h>
 #endif
 #ifdef STARPU_USE_OPENCL
-#include <CL/cl.h>
+#include <starpu_opencl.h>
 #endif
 
 #define INIT_VALUE	42

+ 0 - 1
tests/datawizard/sync_and_notify_data_opencl.c

@@ -17,7 +17,6 @@
 
 #include <starpu.h>
 #include <starpu_opencl.h>
-#include <CL/cl.h>
 
 extern struct starpu_opencl_program opencl_code;
 

+ 0 - 1
tests/datawizard/write_only_tmp_buffer.c

@@ -26,7 +26,6 @@
 starpu_data_handle v_handle;
 
 #ifdef STARPU_USE_OPENCL
-#include <CL/cl.h>
 #include <starpu_opencl.h>
 
 static void opencl_codelet_null(void *descr[], __attribute__ ((unused)) void *_args)