-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathraw_buffer.cu
More file actions
46 lines (39 loc) · 1.46 KB
/
Copy pathraw_buffer.cu
File metadata and controls
46 lines (39 loc) · 1.46 KB
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
#include "raw_buffer.h"
#include <assert.h>
#include "cuda_util.h"
using namespace std;
size_t rawBufferSize(int num_blocks, int num_antennas,
int num_coarse_channels,
int timesteps_per_block, int npol) {
return sizeof(int8_t) * num_blocks * num_antennas * num_coarse_channels *
timesteps_per_block * npol * 2;
}
RawBuffer::RawBuffer(int num_blocks, int num_antennas,
int num_coarse_channels,
int timesteps_per_block, int npol)
: num_blocks(num_blocks), num_antennas(num_antennas),
num_coarse_channels(num_coarse_channels),
timesteps_per_block(timesteps_per_block), npol(npol) {
size = rawBufferSize(num_blocks, num_antennas, num_coarse_channels,
timesteps_per_block, npol);
cudaMallocHost(&data, size);
checkCudaMalloc("RawBuffer", size);
}
RawBuffer::~RawBuffer() {
cudaFreeHost(data);
}
char* RawBuffer::blockPointer(int block) const {
assert(block < num_blocks);
size_t bytes_per_block = size / num_blocks;
return ((char*) data) + (block * bytes_per_block);
}
void RawBuffer::set(int block, int antenna, int coarse_channel,
int timestep, int pol, bool imag, int8_t value) {
int index = 2 * index5d(block, antenna, num_antennas,
coarse_channel, num_coarse_channels,
timestep, timesteps_per_block, pol, npol);
if (imag) {
++index;
}
data[index] = value;
}