-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
42 lines (30 loc) · 1.06 KB
/
main.cpp
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
#include "data_gen.h"
// #include "data_utils.h"
const int32_t WIDTH = 512;
const int32_t HEIGHT = 512;
const int32_t SAMPLES = 1; // SAMPLES * 4 = total samples
#ifndef __CCE_KT_TEST__
#include <acl/acl.h>
extern void render(uint32_t coreDim, void *l2ctrl, void *stream, uint8_t *rays, uint8_t *colors);
#else
#include "tikicpulib.h"
extern "C" __global__ __aicore__ void render(GM_ADDR rays, GM_ADDR colors);
#endif
int main() {
uint32_t blockDim = 8;
uint32_t elementNums = WIDTH * HEIGHT * 4 * SAMPLES;
size_t inputByteSize = elementNums * sizeof(Ray);
size_t outputByteSize = elementNums * sizeof(Vec);
#ifdef __CCE_KT_TEST__
std::vector<Ray>
raysData = genRays(elementNums);
std::vector<Vec> colorsData = stdColor(raysData);
uint8_t *rays = (uint8_t *)AscendC::GmAlloc(inputByteSize);
uint8_t *colors = (uint8_t *)AscendC::GmAlloc(inputByteSize);
AscendC::SetKernelMode(KernelMode::AIV_MODE);
ICPU_RUN_KF(render, blockDim, rays, colors);
AscendC::GmFree((void *)rays);
AscendC::GmFree((void *)colors);
#else
#endif
}