-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel_calls.cuh
95 lines (83 loc) · 3.27 KB
/
kernel_calls.cuh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef WORDER_KERNEL_CALLS_CUH_
#define WORDER_KERNEL_CALLS_CUH_
// C++
#include <iostream>
#include <string>
// CUDA
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
// Package
#include "general.hpp"
#include "kernels.cuh"
namespace kernel_calls
{
// The basic global kernel configurations
constexpr size_t block_size{ 1024 };
constexpr size_t grid_size{ 1024 };
// The number of streams to use
constexpr int n_streams{ 16 };
/// <summary>
/// Executes data processing using CUDA; handles memory de/allocation, copying,
/// launching the kernel and measuring times
/// </summary>
/// <param name="data">The target data</param>
/// <param name="data_length">The length of the data in words</param>
/// <param name="keywords">The list of keywords</param>
/// <param name="histogram">The histogram array to update</param>
/// <param name="compute_time">The kernel execution time from kernel launch
/// to device synchronisation.</param>
/// <param name="total_time">The total time to execute allocation, copying
/// and executing the kernel</param>
/// <exception>Throws an instance of std::runtime_error if any of the
/// CUDA operations fail for whatever reason</exception>
void processDataWithCuda(
const char* data
, const size_t data_length
, const char* keywords
, int* histogram
, float* compute_time
, float* total_time);
/// <summary>
/// Executes data preprocessing and processing using CUDA; handles memory
/// de/allocation, copying, launching the kernel and measuring times
/// </summary>
/// <param name="data">The target data</param>
/// <param name="data_length">The length of the data in words</param>
/// <param name="keywords">The list of keywords</param>
/// <param name="histogram">The histogram array to update</param>
/// <param name="compute_time">The kernel execution time from kernel launch
/// to device synchronisation.</param>
/// <param name="total_time">The total time to execute allocation, copying
/// and executing the kernel</param>
/// <exception>Throws an instance of std::runtime_error if any of the
/// CUDA operations fail for whatever reason</exception>
void processDataWithCudaPreprocess(
const char* data
, const size_t data_length
, const char* keywords
, int* histogram
, float* compute_time
, float* total_time);
/// <summary>
/// Executes data preprocessing and processing using CUDA streams; handles
/// memory de/allocation, copying, launching the kernel and measuring times
/// </summary>
/// <param name="data">The target data</param>
/// <param name="data_length">The length of the data in words</param>
/// <param name="keywords">The list of keywords</param>
/// <param name="histogram">The histogram array to update</param>
/// <param name="compute_time">The kernel execution time from kernel launch
/// to device synchronisation.</param>
/// <param name="total_time">The total time to execute allocation, copying
/// and executing the kernel</param>
/// <exception>Throws an instance of std::runtime_error if any of the
/// CUDA operations fail for whatever reason</exception>
void processDataWithCudaStreamsPreprocess(
const char* data
, const size_t data_length
, const char* keywords
, int* histogram
, float* compute_time
, float* total_time);
}
#endif // WORDER_KERNEL_CALLS_CUH_