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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/* Tom Gall (tom.gall@linaro.org / tom_gall@mac.com)
* Copyright 2014 Linaro
* Released under the terms and conditions of the license documented in the LICENSE file
*/
int opencl_select(opencl_sqlite_context *s, int work_units_per_kernel) {
// cl_event prof_event;
// cl_ulong time_start, time_end, total_time=0;
int stride;
int totalRows, err;
totalRows = s->data_cpu->rows;
stride = s->data_cpu->stride/sizeof(int);
// printf("%d total Rows %d stride\n", totalRows, stride);
err=clSetKernelArg(s->kernel, 0, sizeof(int), &totalRows);
err|=clSetKernelArg(s->kernel, 1, sizeof(int), &(stride));
err|=clSetKernelArg(s->kernel, 2, sizeof(cl_mem), &(s->data_gpu->d));
err|=clSetKernelArg(s->kernel, 3, sizeof(cl_mem), &(s->results_gpu->r));
if (s->results_gpu->roffsetResults_cl)
err|=clSetKernelArg(s->kernel, 4, sizeof(cl_mem), &(s->results_gpu->roffsetResults_cl));
if(err < 0) {
perror("Couldn't set a kernel arg");
exit(1);
}
err = clEnqueueNDRangeKernel(s->queue, s->kernel,
1, // 1 dimention of data
NULL, &work_units_per_kernel,
NULL, 0, NULL, NULL);
if(err < 0) {
perror("Couldn't enqueue the kernel execution command");
exit(1);
}
clFinish(s->queue);
/* clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_START,
sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_END,
sizeof(time_end), &time_end, NULL);
total_time = time_end - time_start;
printf("dispatch time: %llu microseconds\n", total_time/1000);
*/
return OPENCL_SUCCESS;;
}
int opencl_rowcolumn_select(opencl_sqlite_context *s, int work_units_per_kernel) {
// cl_event prof_event;
// cl_ulong time_start, time_end, total_time=0;
// int stride;
int totalRows, err;
totalRows = s->data_cpu->rows;
//stride = s->data_cpu->stride/sizeof(int);
// printf("%d total Rows %d stride\n", totalRows, stride);
err=clSetKernelArg(s->kernel, 0, sizeof(int), &totalRows);
err|=clSetKernelArg(s->kernel, 1, sizeof(cl_mem), &(s->data_gpu->d));
err|=clSetKernelArg(s->kernel, 2, sizeof(cl_mem), &(s->results_gpu->r));
if (s->results_gpu->roffsetResults_cl)
err|=clSetKernelArg(s->kernel, 3, sizeof(cl_mem), &(s->results_gpu->roffsetResults_cl));
if(err < 0) {
perror("Couldn't set a kernel arg");
exit(1);
}
err = clEnqueueNDRangeKernel(s->queue, s->kernel,
1, // 1 dimention of data
NULL, &work_units_per_kernel,
NULL, 0, NULL, NULL);
if(err < 0) {
perror("Couldn't enqueue the kernel execution command");
exit(1);
}
clFinish(s->queue);
/* clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_START,
sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_END,
sizeof(time_end), &time_end, NULL);
total_time = time_end - time_start;
printf("dispatch time: %llu microseconds\n", total_time/1000);
*/
return OPENCL_SUCCESS;
}
int opencl_vector_select(opencl_sqlite_context *s, opencl_data_shard *col1_shard, opencl_data_shard *col2_shard,
int work_units_per_kernel) {
// cl_event prof_event;
// cl_ulong time_start, time_end, total_time=0;
int totalRows, err;
totalRows = s->data_cpu->rows;
// totalRows = 12;
// work_units_per_kernel = 1;
// s->data_cpu->rows = 12;
err=clSetKernelArg(s->kernel, 0, sizeof(int), &totalRows);
err|=clSetKernelArg(s->kernel, 1, sizeof(cl_mem), &(col1_shard->d));
err|=clSetKernelArg(s->kernel, 2, sizeof(cl_mem), &(col2_shard->d));
err|=clSetKernelArg(s->kernel, 3, sizeof(cl_mem), &(s->results_gpu->r));
if(err < 0) {
perror("Couldn't set a kernel arg");
exit(1);
}
err = clEnqueueNDRangeKernel(s->queue, s->kernel,
1, // 1 dimention of data
NULL, &work_units_per_kernel,
NULL, 0, NULL, NULL);
if(err < 0) {
perror("Couldn't enqueue the kernel execution command");
exit(1);
}
clFinish(s->queue);
/* clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_START,
sizeof(time_start), &time_start, NULL);
clGetEventProfilingInfo(prof_event, CL_PROFILING_COMMAND_END,
sizeof(time_end), &time_end, NULL);
total_time = time_end - time_start;
printf("dispatch time: %llu microseconds\n", total_time/1000);
*/
return OPENCL_SUCCESS;
}
|