SkePU(integratedwithStarPU)  0.8.1
 All Classes Namespaces Files Functions Enumerations Friends Macros Groups Pages
globals.h
Go to the documentation of this file.
1 
5 #ifndef _GLOBAL_H_
6 #define _GLOBAL_H_
7 
8 #include <string>
9 #include <iostream>
10 #include <starpu.h>
11 
12 namespace skepu
13 {
14 
15 enum skepu_container_type
16  {
17  VECTOR=0,
18  MATRIX=1,
19  SPARSE_MATRIX=2
20  };
21 
26 #define MAX_GPU_DEVICES 4
27 
28 // based on CUDA programming guide v4.2
29 #define MAX_POSSIBLE_CUDA_STREAMS_PER_GPU 16
30 
31 #ifndef SKEPU_NUMGPU
32  #define SKEPU_NUMGPU 1
33 #elif defined(SKEPU_CUDA) // Only when CUDA is enabled and multi-GPU is possible
34 // #define USE_PINNED_MEMORY
35 #endif
36 
37 // used when checking shared memory and overlap exceeding that in mapoverlap_cu.inl
38 #define SHMEM_SAFITY_BUFFER 30
39 
40 // use it to specify threshold when reduction operation should shift to CPU instead of continuing it on GPU, used in 2D reduction specially.
41 #define REDUCE_GPU_THRESHOLD 50
42 
43 /* A helper method called from SKEPU_EXIT().
44  * Used to delete temp_vector pointers for reduce/mapreduce skeletons
45  * before claling the starpu_shutdown.
46  */
47 void deleteVecPointers();
48 
49 // Macro to exit starpu- user should call this macro before program exit….
50 #define SKEPU_EXIT() { starpu_shutdown(); }
51 
52 
53 // OpenCL additional code that can be supplied in a file. useful when using a custom type with skeletons
54 #define OPENCL_SOURCE_FILE_NAME "opencl_datatype_src.cl"
55 
56 
57 class skepu_error
58 {
59  private:
60  std::string message;
61 
62  public:
63  skepu_error(std::string m) { message = m; }
64  inline std::string getMessage() { return message; };
65  friend std::ostream& operator<<(std::ostream &os, skepu_error& err)
66  {
67  os<<"SKEPU: "<<(err.getMessage())<<"\n";
68  return os;
69  }
70 
71 };
72 
73 #ifndef _NO_EXCEPTION
74 
75 #define REPORT_ERROR(ErrormMsg) throw skepu::skepu_error( ErrormMsg);
76 
77 #else
78 inline void _skepu_error (const char* pErrMsg)
79 {
80  cerr << "SKEPU ERROR: " + pErrMsg << endl;
81  exit(1);
82 }
83 
84 #define REPORT_ERROR(ErrormMsg) skepu::_matrix_error( ErrormMsg);
85 
86 #endif
87 
88 }
89 
90 
91 #ifdef SKEPU_OPENCL
92  #define STARPU_USE_OPENCL
93 #endif
94 
95 
96 
97 #include "src/debug.h"
98 
99 #ifdef SKEPU_CUDA
100 #include "src/skepu_cuda_helpers.h"
101 #endif
102 
103 #ifdef SKEPU_OPENCL
105 #endif
106 
107 #include "src/helper_methods.h"
108 
109 
110 
111 
112 #endif
113 
Contains few helper methods that are used globally by different classes.
Defines a few macros that can be used to output text when debugging. The macros use std::cerr...
Contains the definitions of some helper functions related to CUDA backend.
Contains the definitions of some helper functions related to OpenCL backend.