00001 #ifndef PARALLEL_COMMON_H 00002 #define PARALLEL_COMMON_H 00003 00004 #include <ode/ode.h> 00005 #include <stdlib.h> 00006 #include <vector> 00007 00008 namespace ParallelTypes 00009 { 00010 enum ParallelType { CUDA, OpenCL, OpenMP, None }; 00011 } 00012 typedef ParallelTypes::ParallelType ParallelType; 00013 00014 #if defined(USE_CUDA) 00015 00016 #include <cuda_runtime.h> 00017 #include <math_constants.h> 00018 #include "cuda_common.h" 00019 #define PARALLEL_TYPE CUDA 00020 #define PARALLEL_ENABLED 1 00021 00022 #elif defined(USE_OPENCL) 00023 00024 #include <CL/cl.h> 00025 #include <CL/cl_ext.h> 00026 #include <vector_types.h> 00027 #include <opencl_utils.h> 00028 #include <opencl_common.h> 00029 #define PARALLEL_TYPE OpenCL 00030 #define PARALLEL_ENABLED 1 00031 00032 #ifdef dSINGLE 00033 #define KERNEL_PREFIX "#define make_float4(a) (float4)(a) \n\n" 00034 #define KERNEL_OPTIONS "-D dSINGLE -cl-fast-relaxed-math" 00035 #elif dDOUBLE 00036 #define KERNEL_PREFIX "#pragma OPENCL EXTENSION cl_khr_fp64: enable\n#define make_double4(a) (double4)(a)\n\n" 00037 #define KERNEL_OPTIONS "-D dDOUBLE -cl-fast-relaxed-math" 00038 #endif 00039 00040 #elif defined(USE_OPENMP) 00041 00042 #include <vector_types.h> 00043 #include "openmp_common.h" 00044 #define PARALLEL_TYPE OpenMP 00045 #define PARALLEL_ENABLED 1 00046 00047 #else 00048 00049 #define PARALLEL_TYPE None 00050 #define PARALLEL_ENABLED 0 00051 00052 #endif 00053 00054 #if PARALLEL_ENABLED 00055 #include "parallel_defines.h" 00056 #endif 00057 00058 namespace ParallelOptions 00059 { 00060 enum ParallelOption { 00061 MAXBATCHES = 4, 00062 MAXBODYREPETITION = 31, 00063 BSIZE = 64, 00064 MBSIZE = 96, 00065 MAXTHREADS = 512, 00066 SHAREDMEMORYSIZE = 16384, 00067 MEMALIGN = 128, 00068 DEFAULTALIGN = 32, 00069 FLOATALIGN = MEMALIGN / sizeof(float), 00070 DOUBLEALIGN = MEMALIGN / sizeof(double), 00071 DEFAULTSCALARALIGN = FLOATALIGN }; 00072 } 00073 typedef ParallelOptions::ParallelOption ParallelOption; 00074 00075 typedef size_t ArraySize; 00076 typedef size_t ArrayIndex; 00077 00078 typedef std::vector<int> IntVector; 00079 typedef IntVector::iterator IntVectorIter; 00080 typedef IntVector::const_iterator ConstIntVectorIter; 00081 00082 #define PROJ_NAME "parallel_quickstep" 00083 00084 #endif