diff --git a/hpvm/test/hpvm-cava/Makefile b/hpvm/test/hpvm-cava/Makefile index d172fd9ee2861c4af64a4ee177c65f899941c42f..624f67eacab85f11710284ba2558d803a9bece55 100644 --- a/hpvm/test/hpvm-cava/Makefile +++ b/hpvm/test/hpvm-cava/Makefile @@ -37,8 +37,8 @@ LFLAGS += -pthread ## BEGIN HPVM MAKEFILE LANGUAGE=hpvm -SRCDIR_OBJS= load_cam_model.ll cam_pipe_utility.ll dma_interface.ll utility.ll -OBJS_SRC=src/cam_pipe.c src/pipe_stages.c src/load_cam_model.c src/cam_pipe_utility.c src/dma_interface.c src/utility.c +SRCDIR_OBJS=load_cam_model.ll cam_pipe_utility.ll utility.ll +OBJS_SRC=src/load_cam_model.c src/cam_pipe_utility.c src/utility.c HPVM_OBJS=main.hpvm.ll APP = $(EXE) APP_CUDALDFLAGS=-lm -lstdc++ diff --git a/hpvm/test/hpvm-cava/docs/hpvm-cava_single-node.png b/hpvm/test/hpvm-cava/docs/hpvm-cava_single-node.png deleted file mode 100644 index 5ad1969e9b4b4b6ddf732bcb19a04db498d207bf..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/docs/hpvm-cava_single-node.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-face/README.md b/hpvm/test/hpvm-cava/example-face/README.md deleted file mode 100644 index ad1809141787af7f18ef127a0c620f32496a4114..0000000000000000000000000000000000000000 --- a/hpvm/test/hpvm-cava/example-face/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Example: Face -============= - -As a test, running the camera pipeline on `raw_face_32x32.bin` in this directory should yield a binary image which when converted to PNG is a visible face as in `expected-face.png`. diff --git a/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.bin b/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.bin deleted file mode 100644 index 9f71243e5b0ba1310dd275f33e90f74e4aec6877..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.png b/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.png deleted file mode 100644 index 86047385effccb7c3858e7164203503ea430b5e7..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._raw_tulips.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips.bin deleted file mode 100644 index cffc0a195f18ac0c60ef0ab55b1fb519e4fabdfd..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips.png b/hpvm/test/hpvm-cava/example-tulips/._tulips.png deleted file mode 100644 index c574922bdf1cdffe1dcb6494134e1a6a80c5b3ed..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.bin deleted file mode 100644 index 1e25895f212754691240c8eeeacbff5a8401bd79..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.png b/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.png deleted file mode 100644 index 31ee83eef651ea4a5ac989ebff1e18294d92adce..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_demosaic.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.bin deleted file mode 100644 index a91a546426615bc186cc04c7ceab6dc89005c82f..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.png b/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.png deleted file mode 100644 index 2edebaac99004b7ad40d1d6475e5734e61cdc2ef..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_denoise.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.bin deleted file mode 100644 index f31d0f523f7fd29022fea9a3d6e4bb42ce132573..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.png b/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.png deleted file mode 100644 index 997678345a4bc712d8927222f5941e4af3b16897..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_gamut.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.bin deleted file mode 100644 index 90ad3d71bb17532aa188934febc0e302f6593111..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.png b/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.png deleted file mode 100644 index 93808dcecbbd0365c8416b6d27501186a019a4b0..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_tone.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.bin b/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.bin deleted file mode 100644 index dc85e1f03ff59442c894a8577d57a322922063be..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.bin and /dev/null differ diff --git a/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.png b/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.png deleted file mode 100644 index 2ad111c6a65f4bbdb78dbaffdec7cf28cd6299e5..0000000000000000000000000000000000000000 Binary files a/hpvm/test/hpvm-cava/example-tulips/._tulips_transform.png and /dev/null differ diff --git a/hpvm/test/hpvm-cava/src/cam_pipe_utility.h b/hpvm/test/hpvm-cava/src/cam_pipe_utility.h index a7ba68372aa44a74de588605904fd165a7b98d72..ba56038e1f368c3c182f007c14453d489c9a2cc0 100644 --- a/hpvm/test/hpvm-cava/src/cam_pipe_utility.h +++ b/hpvm/test/hpvm-cava/src/cam_pipe_utility.h @@ -1,7 +1,7 @@ #ifndef _CAM_PIPE_UTILITY_H_ #define _CAM_PIPE_UTILITY_H_ -#include "pipe_stages.h" +#include "defs.h" #include "utility.h" uint8_t *read_image_from_binary(char *file_path, size_t *row_size, diff --git a/hpvm/test/hpvm-cava/src/defs.h b/hpvm/test/hpvm-cava/src/defs.h index 0fa95ef3d2ea55c67a921e0bc5fc8a6ec6ba949f..5396b5ca7fcd39b908f29c659b8f694de4cea212 100644 --- a/hpvm/test/hpvm-cava/src/defs.h +++ b/hpvm/test/hpvm-cava/src/defs.h @@ -7,6 +7,21 @@ typedef unsigned int uint32_t; typedef unsigned long uint64_t; #define CACHELINE_SIZE 64 +#define CHAN_SIZE 3 + +#define max(a, b) \ + ({ \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ + _a > _b ? _a : _b; \ + }) + +#define min(a, b) \ + ({ \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ + _a < _b ? _a : _b; \ + }) // Debugging message macros. #if DEBUG_LEVEL >= 1 diff --git a/hpvm/test/hpvm-cava/src/dma_interface.c b/hpvm/test/hpvm-cava/src/dma_interface.c deleted file mode 100644 index 68698635a4fceb4fe67e323bd0f354bd70bca99d..0000000000000000000000000000000000000000 --- a/hpvm/test/hpvm-cava/src/dma_interface.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "dma_interface.h" -#include <assert.h> -#include <string.h> - -// All _dmaImplN functions must be always inlined or we'll get extra functions -// in the trace. - -#if defined(DMA_INTERFACE_V3) - -// Starting with version 3, all versioning will be distinguished by the return -// value of the DMA functions. - -__attribute__((__always_inline__)) int _dmaImpl3(void *dst_addr, void *src_addr, - size_t size) { - assert(size > 0); - memmove(dst_addr, src_addr, size); - return 3; -} - -int dmaLoad(void *dst_addr, void *src_host_addr, size_t size) { - return _dmaImpl3(dst_addr, src_host_addr, size); -} - -int dmaStore(void *dst_host_addr, void *src_addr, size_t size) { - return _dmaImpl3(dst_host_addr, src_addr, size); -} - -int setReadyBits(void *start_addr, size_t size, unsigned value) { - asm(""); - return 0; -} - -#elif defined(DMA_INTERFACE_V2) - -// With version 2 and earlier, we return (void*)NULL and use the number of -// function arguments to distinguish the DMA functions. - -__attribute__((__always_inline__)) void * -_dmaImpl2(void *base_addr, size_t src_off, size_t dst_off, size_t size) { - assert(size > 0); - memmove(base_addr + dst_off, base_addr + src_off, size); - return NULL; -} - -void *dmaLoad(void *base_addr, size_t src_off, size_t dst_off, size_t size) { - return _dmaImpl2(base_addr, src_off, dst_off, size); -} - -void *dmaStore(void *base_addr, size_t src_off, size_t dst_off, size_t size) { - return _dmaImpl2(base_addr, src_off, dst_off, size); -} - -#else - -__attribute__((__always_inline__)) void *_dmaImpl1(void *base_addr, - size_t offset, size_t size) { - assert(size > 0); - asm(""); - return NULL; -} - -void *dmaLoad(void *addr, size_t offset, size_t size) { - return _dmaImpl1(addr, offset, size); -} - -void *dmaStore(void *addr, size_t offset, size_t size) { - return _dmaImpl1(addr, offset, size); -} -#endif - -void dmaFence() { asm(""); } diff --git a/hpvm/test/hpvm-cava/src/dma_interface.h b/hpvm/test/hpvm-cava/src/dma_interface.h deleted file mode 100644 index 771ece523824cff5923581aca671ab7d26fae706..0000000000000000000000000000000000000000 --- a/hpvm/test/hpvm-cava/src/dma_interface.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __DMA_INTERFACE_H__ -#define __DMA_INTERFACE_H__ - -#include <stddef.h> - -#define PAGE_SIZE 4096 - -#if defined(DMA_INTERFACE_V3) - -// Version 3 of the DMA interface enables memcpy operations from arbitrary -// source and destination addresses. - -int dmaLoad(void *dst_addr, void *src_host_addr, size_t size); -int dmaStore(void *dst_host_addr, void *src_addr, size_t size); - -// The user can explicitly toggle the state of ready bits, if ready mode is -// enabled. This requires support from DMA v3. -int setReadyBits(void *start_addr, size_t size, unsigned value); - -#elif defined(DMA_INTERFACE_V2) - -#warning "DMA interface v2 is deprecated!" - -// Version 2 of the DMA interface separates source and destination offsets from -// the base address into different fields, and on the host machine, memory is -// actually copied from source to destination (the memory copy will not show up -// in the trace). - -void *dmaLoad(void *base_addr, size_t src_off, size_t dst_off, size_t size); -void *dmaStore(void *base_addr, size_t src_off, size_t dst_off, size_t size); - -#else - -#warning "DMA interface v1 is deprecated!" - -// Version 1 of the DMA interface is now deprecated and will be removed -// entirely. - -void *dmaLoad(void *addr, size_t offset, size_t size); -void *dmaStore(void *addr, size_t offset, size_t size); - -#endif -void dmaFence(); - -#endif diff --git a/hpvm/test/hpvm-cava/src/load_cam_model.c b/hpvm/test/hpvm-cava/src/load_cam_model.c index dffb12b04b1e8f1cc56060737527a33de074d4a5..41ff7dac23042d4787445f66824d72ca7074aa68 100644 --- a/hpvm/test/hpvm-cava/src/load_cam_model.c +++ b/hpvm/test/hpvm-cava/src/load_cam_model.c @@ -3,8 +3,8 @@ #include <stdlib.h> #include <string.h> +#include "defs.h" #include "utility.h" -#include "pipe_stages.h" #include "load_cam_model.h" // Get color space transform diff --git a/hpvm/test/hpvm-cava/src/main.c b/hpvm/test/hpvm-cava/src/main.c index 628660f74cf2f55fa47d77991758b0528aec70d1..09430239d7c06a0b2fab2a59c7e6310babe617c6 100644 --- a/hpvm/test/hpvm-cava/src/main.c +++ b/hpvm/test/hpvm-cava/src/main.c @@ -1,4 +1,5 @@ #include "utility.h" +#include "defs.h" #include <argp.h> #include <assert.h> #include <math.h> @@ -8,7 +9,6 @@ #include "cam_pipe_utility.h" #include "load_cam_model.h" -#include "pipe_stages.h" #include "hpvm.h" diff --git a/hpvm/test/hpvm-cava/src/pipe_stages.c b/hpvm/test/hpvm-cava/src/pipe_stages.c deleted file mode 100644 index 05bb06697fa8df130aa0d0d324f9bc39bc575fb2..0000000000000000000000000000000000000000 --- a/hpvm/test/hpvm-cava/src/pipe_stages.c +++ /dev/null @@ -1,284 +0,0 @@ -#include "pipe_stages.h" -#include "cam_pipe_utility.h" -#include <math.h> -#include <stdio.h> - -// void scale_fxp(uint8_t *input, int row_size, int col_size, float *output) { -void scale_fxp(uint8_t *input, size_t bytes_input, float *output, - size_t bytes_output, int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(2, input, output, 1, output); - - ARRAY_3D(uint8_t, _input, input, row_size, col_size); - ARRAY_3D(float, _output, output, row_size, col_size); -sl_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) - sl_row: - for (int row = 0; row < row_size; row++) - sl_col: - for (int col = 0; col < col_size; col++) - _output[chan][row][col] = _input[chan][row][col] * 1.0 / 255; - - __hpvm__return(1, bytes_output); -} - -// void descale_fxp(float *input, int row_size, int col_size, uint8_t *output) { -void descale_fxp(float *input, size_t bytes_input, uint8_t *output, - size_t bytes_result, int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(2, input, output, 1, output); - - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(uint8_t, _output, output, row_size, col_size); -dsl_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) - dsl_row: - for (int row = 0; row < row_size; row++) - dsl_col: - for (int col = 0; col < col_size; col++) - _output[chan][row][col] = - min(max(_input[chan][row][col] * 255, 0), 255); - - __hpvm__return(1, bytes_output); -} - -// Demosaicing stage -// G R -// B G -// void demosaic_fxp(float *input, int row_size, int col_size, float *result) { -void demosaic_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(2, input, result, 1, result); - - printf("Demosaicing.\n"); - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(float, _result, result, row_size, col_size); - -dm_row: - for (int row = 1; row < row_size - 1; row++) - dm_col: - for (int col = 1; col < col_size - 1; col++) - if (row % 2 == 0 && col % 2 == 0) { - // Green pixel - // Getting the R values - float R1 = _input[0][row][col - 1]; - float R2 = _input[0][row][col + 1]; - // Getting the B values - float B1 = _input[2][row - 1][col]; - float B2 = _input[2][row + 1][col]; - // R - _result[0][row][col] = (R1 + R2) / 2; - // G - _result[1][row][col] = _input[1][row][col] * 2; - // B - _result[2][row][col] = (B1 + B2) / 2; - } else if (row % 2 == 0 && col % 2 == 1) { - // Red pixel - // Getting the G values - float G1 = _input[1][row - 1][col]; - float G2 = _input[1][row + 1][col]; - float G3 = _input[1][row][col - 1]; - float G4 = _input[1][row][col + 1]; - // Getting the B values - float B1 = _input[2][row - 1][col - 1]; - float B2 = _input[2][row - 1][col + 1]; - float B3 = _input[2][row + 1][col - 1]; - float B4 = _input[2][row + 1][col + 1]; - // R - _result[0][row][col] = _input[0][row][col]; - // G - _result[1][row][col] = (G1 + G2 + G3 + G4) / 2; - // B (center pixel) - _result[2][row][col] = (B1 + B2 + B3 + B4) / 4; - } else if (row % 2 == 1 && col % 2 == 0) { - // Blue pixel - // Getting the R values - float R1 = _input[0][row - 1][col - 1]; - float R2 = _input[0][row + 1][col - 1]; - float R3 = _input[0][row - 1][col + 1]; - float R4 = _input[0][row + 1][col + 1]; - // Getting the G values - float G1 = _input[1][row - 1][col]; - float G2 = _input[1][row + 1][col]; - float G3 = _input[1][row][col - 1]; - float G4 = _input[1][row][col + 1]; - // R - _result[0][row][col] = (R1 + R2 + R3 + R4) / 4; - // G - _result[1][row][col] = (G1 + G2 + G3 + G4) / 2; - // B - _result[2][row][col] = _input[2][row][col]; - } else { - // Bottom Green pixel - // Getting the R values - float R1 = _input[0][row - 1][col]; - float R2 = _input[0][row + 1][col]; - // Getting the B values - float B1 = _input[2][row][col - 1]; - float B2 = _input[2][row][col + 1]; - // R - _result[0][row][col] = (R1 + R2) / 2; - // G - _result[1][row][col] = _input[1][row][col] * 2; - // B - _result[2][row][col] = (B1 + B2) / 2; - } - - __hpvm__return(1, bytes_result); -} - -static void sort(float arr[], int n) { - int i, j; -dn_sort_i: - for (i = 0; i < n - 1; i++) - dn_sort_j: - for (j = 0; j < n - i - 1; j++) - if (arr[j] > arr[j + 1]) { - float temp = arr[j]; - arr[j] = arr[j + 1]; - arr[j + 1] = temp; - } -} - -// Simple denoise -// void denoise_fxp(float *input, int row_size, int col_size, float *result) { -void denoise_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(2, input, result, 1, result); - - printf("Denoising.\n"); - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(float, _result, result, row_size, col_size); - -dn_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) - dn_row: - for (int row = 0; row < row_size; row++) - dn_col: - for (int col = 0; col < col_size; col++) - if (row >= 1 && row < row_size - 1 && col >= 1 && col < col_size - 1) { - float filter[9]; - dn_slide_row: - for (int i = row - 1; i < row + 2; i++) - dn_slide_col: - for (int j = col - 1; j < col + 2; j++) { - int index = (i - row + 1) * 3 + j - col + 1; - filter[index] = _input[chan][i][j]; - } - sort(filter, 9); - _result[chan][row][col] = filter[4]; - } else { - _result[chan][row][col] = _input[chan][row][col]; - } - __hpvm__return(1, bytes_result); -} - -// Color map and white balance transform -// void transform_fxp(float *input, int row_size, int col_size, float *result, -// float *TsTw_tran) { -void transform_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *TsTw_tran, size_t bytes_TsTw, - int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(3, input, result, TsTw_tran, 1, result); - - printf("Color mapping.\n"); - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(float, _result, result, row_size, col_size); - ARRAY_2D(float, _TsTw_tran, TsTw_tran, 3); - -tr_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) - tr_row: - for (int row = 0; row < row_size; row++) - tr_col: - for (int col = 0; col < col_size; col++) - _result[chan][row][col] = - max(_input[0][row][col] * _TsTw_tran[0][chan] + - _input[1][row][col] * _TsTw_tran[1][chan] + - _input[2][row][col] * _TsTw_tran[2][chan], - 0); - __hpvm__return(1, bytes_result); -} - -// -// Weighted radial basis function for gamut mapping -// -// void gamut_map_fxp(float *input, int row_size, int col_size, float *result, -// float *ctrl_pts, float *weights, float *coefs, float -// *l2_dist) { -void gamut_map_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *ctrl_pts, size_t bytes_ctrl_pts, - float *weights, size_t bytes_weights, float *coefs, - size_t bytes_coefs, float *l2_dist, size_t bytes_l2_dist, - int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(6, input, result, ctrl_pts, weights, coefs, l2_dist, 1, - result); - - printf("Gamut mapping.\n"); - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(float, _result, result, row_size, col_size); - ARRAY_2D(float, _ctrl_pts, ctrl_pts, 3); - ARRAY_2D(float, _weights, weights, 3); - ARRAY_2D(float, _coefs, coefs, 3); - -// First, get the L2 norm from every pixel to the control points, -// Then, sum it and weight it. Finally, add the bias. -gm_rbf_row: - for (int row = 0; row < row_size; row++) - gm_rbf_col: - for (int col = 0; col < col_size; col++) { - gm_rbf_cp0: - for (int cp = 0; cp < num_ctrl_pts; cp++) { - l2_dist[cp] = sqrt((_input[0][row][col] - _ctrl_pts[cp][0]) * - (_input[0][row][col] - _ctrl_pts[cp][0]) + - (_input[1][row][col] - _ctrl_pts[cp][1]) * - (_input[1][row][col] - _ctrl_pts[cp][1]) + - (_input[2][row][col] - _ctrl_pts[cp][2]) * - (_input[2][row][col] - _ctrl_pts[cp][2])); - } - gm_rbf_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) { - float chan_val = 0.0; - gm_rbf_cp1: - for (int cp = 0; cp < num_ctrl_pts; cp++) { - chan_val += l2_dist[cp] * _weights[cp][chan]; - } - // Add on the biases for the RBF - chan_val += _coefs[0][chan] + _coefs[1][chan] * _input[0][row][col] + - _coefs[2][chan] * _input[1][row][col] + - _coefs[3][chan] * _input[2][row][col]; - _result[chan][row][col] = max(chan_val, 0); - } - } - __hpvm__return(1, bytes_result); -} - -// Tone mapping -// void tone_map_fxp(float *input, int row_size, int col_size, float *tone_map, -// float *result) { -void tone_map_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *tone_map, size_t bytes_tone_map, - int row_size, int col_size) { - __hpvm__hint(DEVICE); - __hpvm__attributes(3, input, result, tone_map, 1, result); - - printf("Tone mapping.\n"); - ARRAY_3D(float, _input, input, row_size, col_size); - ARRAY_3D(float, _result, result, row_size, col_size); - ARRAY_2D(float, _tone_map, tone_map, 3); - -tm_chan: - for (int chan = 0; chan < CHAN_SIZE; chan++) - tm_row: - for (int row = 0; row < row_size; row++) - tm_col: - for (int col = 0; col < col_size; col++) { - uint8_t x = _input[chan][row][col] * 255; - _result[chan][row][col] = _tone_map[x][chan]; - } - __hpvm__return(1, bytes_result); -} diff --git a/hpvm/test/hpvm-cava/src/pipe_stages.h b/hpvm/test/hpvm-cava/src/pipe_stages.h deleted file mode 100644 index f960822a03326638189c8d294938452ba2670b41..0000000000000000000000000000000000000000 --- a/hpvm/test/hpvm-cava/src/pipe_stages.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef _PIPE_STAGES_H_ -#define _PIPE_STAGES_H_ - -#include "defs.h" - -#define CHAN_SIZE 3 - -#define ISP 0x4 - -#define max(a, b) \ - ({ \ - __typeof__(a) _a = (a); \ - __typeof__(b) _b = (b); \ - _a > _b ? _a : _b; \ - }) - -#define min(a, b) \ - ({ \ - __typeof__(a) _a = (a); \ - __typeof__(b) _b = (b); \ - _a < _b ? _a : _b; \ - }) - -#define abs(a) \ - ({ \ - __typeof__(a) _a = (a); \ - _a < 0 ? -_a : _a; \ - }) - -extern int num_ctrl_pts; - -void scale_fxp(uint8_t *input, size_t bytes_input, float *output, - size_t bytes_output, size_t row_size, size_t col_size); - -void descale_fxp(float *input, size_t bytes_input, uint8_t *output, - size_t bytes_result, size_t row_size, size_t col_size); - -void demosaic_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, size_t row_size, size_t col_size); - -void denoise_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, size_t row_size, size_t col_size); - -void transform_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *TsTw_tran, size_t bytes_TsTw, - size_t row_size, size_t col_size); - -void gamut_map_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *ctrl_pts, size_t bytes_ctrl_pts, - float *weights, size_t bytes_weights, float *coefs, - size_t bytes_coefs, float *l2_dist, size_t bytes_l2_dist, - size_t row_size, size_t col_size); - -void tone_map_fxp(float *input, size_t bytes_input, float *result, - size_t bytes_result, float *tone_map, size_t bytes_tone_map, - size_t row_size, size_t col_size); - -void tone_map_approx_fxp(float *input, size_t row_size, size_t col_size, - float *result); - -#endif