Skip to content
Snippets Groups Projects
Commit 8dcf6d55 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Merge branch 'hpvm-release/hotfix' into hpvm-release-exp

parents 8f116f71 d8d55c3e
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,8 @@
*cr
***************************************************************************/
// This changes hpvm::DEVICE (backward-compatible hint name) to hpvm::CUDNN_TARGET.
// hpvm::DEVICE is deprecated; do not use.
#ifndef DEVICE
#define DEVICE CUDNN_TARGET
#endif
......
......@@ -34,5 +34,22 @@ function(add_hpvm_benchmark
add_custom_target(${target_name} DEPENDS ${output_bin_path})
endfunction(add_hpvm_benchmark)
function(add_hpvm_cpu_gpu_benchmark
target_prefix common_flags language_mode main_src util_bitcodes
)
set(all_flags_cpu ${common_flags} "-DDEVICE=CPU_TARGET")
add_hpvm_benchmark(
"${target_prefix}_cpu" "${target_prefix}-cpu" "${all_flags_cpu}" ${language_mode}
${main_src} "${util_bitcodes}"
)
if(HPVM_USE_OPENCL)
set(all_flags_gpu ${common_flags} "--opencl" "-DDEVICE=GPU_TARGET")
add_hpvm_benchmark(
"${target_prefix}_gpu" "${target_prefix}-gpu" "${all_flags_gpu}" ${language_mode}
${main_src} "${util_bitcodes}"
)
endif()
endfunction()
add_subdirectory(hpvm-cava)
add_subdirectory(pipeline)
......@@ -8,17 +8,4 @@ set(
# Sets ${util_bitcodes}
hpvm_compile_util_sources("${compiler_flags}" "${other_srcs}" "c")
set(all_flags_cpu ${compiler_flags} "-DDEVICE=CPU_TARGET" "-lpthread")
add_hpvm_benchmark(
"hpvm_cava_cpu" "hpvm-cava-cpu" "${all_flags_cpu}" "c"
src/main.c "${util_bitcodes}"
)
if(HPVM_USE_OPENCL)
set(all_flags_gpu ${compiler_flags} "-DDEVICE=GPU_TARGET" "--opencl" "-lpthread")
add_hpvm_benchmark(
"hpvm_cava_gpu" "hpvm-cava-gpu" "${all_flags_gpu}" "c"
src/main.c "${util_bitcodes}"
)
endif()
add_hpvm_cpu_gpu_benchmark(hpvm_cava "${compiler_flags}" c src/main.c "${util_bitcodes}")
......@@ -12,6 +12,9 @@
#include "hpvm.h"
// Max file extension size
#define MAX_EXT_SIZE 20
int NUM_TEST_CASES;
int NUM_CLASSES;
int INPUT_DIM;
......@@ -875,29 +878,33 @@ int main(int argc, char *argv[]) {
// Output the image.
// 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(str, base_str);
strcat(str, ".bin");
strncat(str, ".bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out, row_size, col_size);
strcpy(str, base_str);
strcat(str, "_gamut.bin");
strncat(str, "_gamut.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_gamut, row_size, col_size);
strcpy(str, base_str);
strcat(str, "_demosaic.bin");
strncat(str, "_demosaic.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_demosaic, row_size, col_size);
strcpy(str, base_str);
strcat(str, "_denoise.bin");
strncat(str, "_denoise.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_denoise, row_size, col_size);
strcpy(str, base_str);
strcat(str, "_transform.bin");
strncat(str, "_transform.bin", MAX_EXT_SIZE);
printf("Writing output image to %s\n", str);
write_image_to_binary(str, image_out_transform, row_size, col_size);
free(str);
__hpvm__cleanup();
return 0;
......
find_package(OpenCV 2)
if(${OpenCV_FOUND})
set(
all_flags
-O3 -I${OpenCV_INCLUDE_DIRS}
-ffast-math -fno-lax-vector-conversions -fno-vectorize -fno-slp-vectorize
-lpthread
foreach(incl_dir ${OpenCV_INCLUDE_DIRS})
list(APPEND all_flags "-I${incl_dir}")
endforeach()
foreach(link_lib ${OpenCV_LIBS})
list(APPEND all_flags "-l${link_lib}")
endforeach()
list(
APPEND all_flags -L "${OpenCV_INSTALL_PATH}/lib"
-O3 -ffast-math -fno-lax-vector-conversions -fno-vectorize -fno-slp-vectorize
)
add_hpvm_benchmark("pipeline_cpu" "pipeline-cpu" "${all_flags}" "c++" src/main.cc "")
if(HPVM_USE_OPENCL)
add_hpvm_benchmark("pipeline_gpu" "pipeline-gpu" "${all_flags};--opencl" "c++" src/main.cc "")
endif()
add_hpvm_cpu_gpu_benchmark("pipeline" "${all_flags}" c++ src/main.cc "")
else()
message(WARNING "opencv-2 not found; not compiling HPVM benchmark 'pipeline'.")
endif()
......@@ -27,6 +27,10 @@
#define HEIGHT 640
#define WIDTH 480
#ifndef DEVICE
#error "The macro 'DEVICE' must be defined to CPU_TARGET or GPU_TARGET."
#endif
std::string input_window = "GPU Pipeline - Input Video";
std::string output_window = "GPU Pipeline - Edge Mapping";
......
......@@ -40,6 +40,9 @@ def compile_hpvm_c(
):
from subprocess import check_output
# FIXME: Added this because Exceptions are not supported in HPVM.
flags = (flags or []) + ["no-exceptions"]
passes = ["LLVMBuildDFG"]
pass_flags = ["buildDFG"]
if tensor_target == "tensor":
......@@ -229,8 +232,8 @@ See option -b for that."""
help="[clang emit-llvm] clang++ flags (such as -ffastmath)"
)
parser.add_argument(
"-O", type=str, default="0", metavar="level",
help="[clang emit-llvm] Optimization level"
"-O", type=str, default="1", metavar="level",
help="[clang emit-llvm] Optimization level. Note that default is -O1."
)
parser.add_argument(
"--std", type=str,
......
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