@@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
41
#include " mkn/gpu/cli.hpp"
42
42
#include " mkn/gpu/def.hpp"
43
43
44
+ #include < algorithm>
44
45
#include < cassert>
45
46
#include < cstring>
46
47
@@ -62,18 +63,23 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
63
#endif
63
64
64
65
// we need to exclude these for CPU only operations
66
+ #define __shared__
65
67
#define __device__
66
68
#define __host__
67
69
#define __global__
70
+ #define __syncthreads (...)
68
71
69
72
#if defined(MKN_GPU_FN_PER_NS) && MKN_GPU_FN_PER_NS
70
73
#define MKN_GPU_NS mkn::gpu::cpu
71
74
#else
72
75
#define MKN_GPU_NS mkn::gpu
73
76
#endif // MKN_GPU_FN_PER_NS
74
77
75
- namespace MKN_GPU_NS {
78
+ #if !defined(MKN_CPU_DO_NOT_DEFINE_DIM3)
79
+ #define MKN_CPU_DO_NOT_DEFINE_DIM3 0
80
+ #endif
76
81
82
+ #if !defined(dim3) and !MKN_CPU_DO_NOT_DEFINE_DIM3
77
83
struct dim3 {
78
84
dim3 () {}
79
85
dim3 (std::size_t x) : x{x} {}
@@ -83,6 +89,14 @@ struct dim3 {
83
89
std::size_t x = 1 , y = 1 , z = 1 ;
84
90
};
85
91
92
+ dim3 static inline threadIdx, blockIdx;
93
+
94
+ #endif // MKN_CPU_DO_NOT_DEFINE_DIM3
95
+
96
+ //
97
+
98
+ namespace MKN_GPU_NS {
99
+
86
100
void inline setLimitMallocHeapSize (std::size_t const & /* bytes*/ ) {} /* noop*/
87
101
88
102
void inline setDevice (std::size_t const & /* dev*/ ) {} /* noop*/
@@ -256,14 +270,24 @@ struct GLauncher : public Launcher {
256
270
std::size_t count;
257
271
};
258
272
273
+ template <typename Container, typename T>
274
+ void fill (Container& c, size_t const size, T const val) {
275
+ std::fill (c.begin (), c.begin () + size, val);
276
+ }
277
+
278
+ template <typename Container, typename T>
279
+ void fill (Container& c, T const val) {
280
+ fill (c, c.size (), val);
281
+ }
282
+
259
283
void inline prinfo (std::size_t /* dev*/ = 0 ) { KOUT (NON) << " Psuedo GPU in use" ; }
260
284
261
285
} // namespace MKN_GPU_NS
262
286
263
287
namespace mkn ::gpu::cpu {
264
288
265
289
template <typename SIZE = std::uint32_t /* max 4294967296*/ >
266
- SIZE idx () {
290
+ SIZE inline idx () {
267
291
return MKN_GPU_NS::detail::idx;
268
292
}
269
293
0 commit comments