-
Notifications
You must be signed in to change notification settings - Fork 1
/
CLManager.mm
41 lines (39 loc) · 899 Bytes
/
CLManager.mm
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
#import "gp_types.h"
#import "CLManager.h"
#import "Util.h"
void CLManager::Init() {
try {
Load("CLOperator", "CLOperator.cl");
}
catch (const char *msg) {
fprintf(stderr, "failed: %s\n", msg);
exit(1);
}
}
void CLManager::Run(GPVars *vars, int numChannels, void (^post)(int32_t *)) {
if (numChannels <= 0) return;
try {
MeasureTime<0> _;
Buffer varsD, sampleBufferD;
varsD.Init(this, sizeof(GPVars));
sampleBufferD.Init(this, sizeof(int32_t) * GP_CH_N * vars->numSamples);
varsD.Write(vars);
SetArg(varsD);
SetArg(sampleBufferD);
{
MeasureTime<1> _;
Execute(numChannels << 3);
Finish();
}
varsD.Read(vars);
int32_t *sampleBuffer = new int32_t[GP_CH_N * vars->numSamples];
sampleBufferD.Read(sampleBuffer);
Finish();
post(sampleBuffer);
delete[] sampleBuffer;
}
catch (const char *msg) {
fprintf(stderr, "failed: %s\n", msg);
exit(1);
}
}