diff --git a/hpvm/include/hpvm.h b/hpvm/include/hpvm.h index 9e2e6bc36e488a0d3e61bf0e2e8171bdce064115..f76dde028e61d2c940a15fc34e1dda10431a06b8 100644 --- a/hpvm/include/hpvm.h +++ b/hpvm/include/hpvm.h @@ -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 diff --git a/hpvm/test/benchmarks/CMakeLists.txt b/hpvm/test/benchmarks/CMakeLists.txt index 4d4f0691fc0e70cd9b532947688da264b2ca4e7b..ab12243bebac18a1570a1cd05e90b5309faed84a 100644 --- a/hpvm/test/benchmarks/CMakeLists.txt +++ b/hpvm/test/benchmarks/CMakeLists.txt @@ -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) diff --git a/hpvm/test/benchmarks/hpvm-cava/CMakeLists.txt b/hpvm/test/benchmarks/hpvm-cava/CMakeLists.txt index d89a01a05669a0c49fecf1ccbd25029fce14143b..33867168d10f6ed34eb067df9792fdbef9b76276 100644 --- a/hpvm/test/benchmarks/hpvm-cava/CMakeLists.txt +++ b/hpvm/test/benchmarks/hpvm-cava/CMakeLists.txt @@ -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}") diff --git a/hpvm/test/benchmarks/hpvm-cava/src/main.c b/hpvm/test/benchmarks/hpvm-cava/src/main.c index 0d8fb37d0103b55234e59e8d2b66742faed207b6..3d26a9c45628c5961b45bd4ba11a11283c03eb92 100644 --- a/hpvm/test/benchmarks/hpvm-cava/src/main.c +++ b/hpvm/test/benchmarks/hpvm-cava/src/main.c @@ -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; diff --git a/hpvm/test/benchmarks/pipeline/CMakeLists.txt b/hpvm/test/benchmarks/pipeline/CMakeLists.txt index db2b8eeab1647f4ac72c05127877ecec1f949c90..cede337ca2f606a9008056f42ad0b8b9c5aec00c 100644 --- a/hpvm/test/benchmarks/pipeline/CMakeLists.txt +++ b/hpvm/test/benchmarks/pipeline/CMakeLists.txt @@ -1,15 +1,16 @@ 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() diff --git a/hpvm/test/benchmarks/pipeline/src/main.cc b/hpvm/test/benchmarks/pipeline/src/main.cc index 057c13b62745ba618b13b9f2c1443fb41ca45bdb..5fcb205ca7b441d5e01c7c797bc34d53428f1a12 100644 --- a/hpvm/test/benchmarks/pipeline/src/main.cc +++ b/hpvm/test/benchmarks/pipeline/src/main.cc @@ -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"; diff --git a/hpvm/tools/hpvm-clang/main.py.in b/hpvm/tools/hpvm-clang/main.py.in index b20af0b80f192fe3c87b004c05a72b034aee098d..f20bae4df9a461bb0714af54a95e36e3a424816d 100644 --- a/hpvm/tools/hpvm-clang/main.py.in +++ b/hpvm/tools/hpvm-clang/main.py.in @@ -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,