From af20594cc4d7262a3fc3db94fc0df497eef87ca7 Mon Sep 17 00:00:00 2001 From: nhatdongdang <144138246+nhatdongdang@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:28:38 +1000 Subject: [PATCH] Add O3 to cmake --- .clang-format | 2 +- CMakeLists.txt | 5 +++-- speed_demo_cpu.sh | 31 +++++++++++++++++++++++++++++++ speed_demo_gpu.sh | 31 +++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 speed_demo_cpu.sh create mode 100644 speed_demo_gpu.sh diff --git a/.clang-format b/.clang-format index 9b809ef..3aced12 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,5 @@ BasedOnStyle: LLVM IndentWidth: 4 PointerAlignment: Left -ColumnLimit: 80 +ColumnLimit: 120 AlwaysBreakTemplateDeclarations: true \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f2714e7..7bc6a5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.10) # Set the project name -project(hpc) +project(ichida-algo) +set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra") set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED True) -add_executable(model src/main.c) \ No newline at end of file +add_executable(speed_cpu src/main.c) \ No newline at end of file diff --git a/speed_demo_cpu.sh b/speed_demo_cpu.sh new file mode 100644 index 0000000..45b6f91 --- /dev/null +++ b/speed_demo_cpu.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: speed_cpu " + exit 1 +fi + +weights_and_biases=$1 +input_tensor_dir=$2 + +binary="speed_cpu" + +if [ ! -f "$binary" ]; then + echo "Binary $binary not found!" + exit 1 +fi + +start_time=$(date +%s) +./$binary "$weights_and_biases" "$input_tensor_dir" + +end_time=$(date +%s) +execution_time=$((end_time - start_time)) + +if [ ! -f "results.csv" ]; then + echo "Error: results.csv not found!" + exit 1 +else + echo "results.csv found!" +fi + +echo "Execution time: $execution_time seconds" diff --git a/speed_demo_gpu.sh b/speed_demo_gpu.sh new file mode 100644 index 0000000..3a6942e --- /dev/null +++ b/speed_demo_gpu.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: speed_gpu " + exit 1 +fi + +weights_and_biases=$1 +input_tensor_dir=$2 + +binary="speed_gpu" + +if [ ! -f "$binary" ]; then + echo "Binary $binary not found!" + exit 1 +fi + +start_time=$(date +%s) +./$binary "$weights_and_biases" "$input_tensor_dir" + +end_time=$(date +%s) +execution_time=$((end_time - start_time)) + +if [ ! -f "results.csv" ]; then + echo "Error: results.csv not found!" + exit 1 +else + echo "results.csv found!" +fi + +echo "Execution time: $execution_time seconds"