forked from jlgreathouse/BabelStream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SYCLStream.h
73 lines (56 loc) · 1.72 KB
/
SYCLStream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2015-16 Tom Deakin, Simon McIntosh-Smith,
// University of Bristol HPC
//
// For full license terms please see the LICENSE file distributed with this
// source code
#pragma once
#include <sstream>
#include "Stream.h"
#include "CL/sycl.hpp"
#define IMPLEMENTATION_STRING "SYCL"
namespace sycl_kernels
{
template <class T> class init;
template <class T> class copy;
template <class T> class mul;
template <class T> class add;
template <class T> class triad;
template <class T> class dot;
}
template <class T>
class SYCLStream : public Stream<T>
{
protected:
// Size of arrays
unsigned int array_size;
// SYCL objects
cl::sycl::queue *queue;
cl::sycl::buffer<T> *d_a;
cl::sycl::buffer<T> *d_b;
cl::sycl::buffer<T> *d_c;
cl::sycl::buffer<T> *d_sum;
// SYCL kernel names
typedef sycl_kernels::init<T> init_kernel;
typedef sycl_kernels::copy<T> copy_kernel;
typedef sycl_kernels::mul<T> mul_kernel;
typedef sycl_kernels::add<T> add_kernel;
typedef sycl_kernels::triad<T> triad_kernel;
typedef sycl_kernels::dot<T> dot_kernel;
// NDRange configuration for the dot kernel
size_t dot_num_groups;
size_t dot_wgsize;
public:
SYCLStream(const unsigned int, const int);
~SYCLStream();
virtual float read() override;
virtual float write() override;
virtual float copy() override;
virtual float add() override;
virtual float mul() override;
virtual float triad() override;
virtual T dot() override;
virtual void init_arrays(T initA, T initB, T initC) override;
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) override;
};
// Populate the devices list
void getDeviceList(void);