Skip to content
Snippets Groups Projects
Commit 6e835b56 authored by leonkm2's avatar leonkm2 Committed by Yifan Zhao
Browse files

Make hpvm-cava allocate file paths dynamically

parent c773999d
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "hpvm.h" #include "hpvm.h"
// Max file extension size
#define MAX_EXT_SIZE 20
int NUM_TEST_CASES; int NUM_TEST_CASES;
int NUM_CLASSES; int NUM_CLASSES;
int INPUT_DIM; int INPUT_DIM;
...@@ -875,29 +878,33 @@ int main(int argc, char *argv[]) { ...@@ -875,29 +878,33 @@ int main(int argc, char *argv[]) {
// Output the image. // Output the image.
// NOTE: We deliberately perform this file I/O outside of the kernel. // NOTE: We deliberately perform this file I/O outside of the kernel.
char str[50], base_str[50]; const int len = strlen(args.args[OUTPUT_IMAGE_BIN]);
const char *base_str = args.args[OUTPUT_IMAGE_BIN];
char *str = malloc(sizeof(char)*len + MAX_EXT_SIZE + 1); // Handles the extensions below
strcpy(base_str, args.args[OUTPUT_IMAGE_BIN]); strcpy(base_str, args.args[OUTPUT_IMAGE_BIN]);
strcpy(str, base_str); strcpy(str, base_str);
strcat(str, ".bin"); strncat(str, ".bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str); printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out, row_size, col_size); write_image_to_binary(str, image_out, row_size, col_size);
strcpy(str, base_str); strcpy(str, base_str);
strcat(str, "_gamut.bin"); strncat(str, "_gamut.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str); printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_gamut, row_size, col_size); write_image_to_binary(str, image_out_gamut, row_size, col_size);
strcpy(str, base_str); strcpy(str, base_str);
strcat(str, "_demosaic.bin"); strncat(str, "_demosaic.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str); printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_demosaic, row_size, col_size); write_image_to_binary(str, image_out_demosaic, row_size, col_size);
strcpy(str, base_str); strcpy(str, base_str);
strcat(str, "_denoise.bin"); strncat(str, "_denoise.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str); printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_denoise, row_size, col_size); write_image_to_binary(str, image_out_denoise, row_size, col_size);
strcpy(str, base_str); strcpy(str, base_str);
strcat(str, "_transform.bin"); strncat(str, "_transform.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str); printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_transform, row_size, col_size); write_image_to_binary(str, image_out_transform, row_size, col_size);
free(str);
__hpvm__cleanup(); __hpvm__cleanup();
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment