Skip to content

Commit

Permalink
ok for cuda and hip but not for sycl
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetyusufoglu committed Dec 19, 2024
1 parent 0c38768 commit c54d776
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions script/hal_specific_scripts/compileRunBabel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil # Added shutil for directory operations
import subprocess
import multiprocessing
from datetime import datetime
Expand Down Expand Up @@ -59,6 +60,13 @@ def build_babelstream():
num_cores = max(1, multiprocessing.cpu_count() - 2)
os.chdir("alpaka")
boost_path = subprocess.run("spack location -i /u3oct6d", shell=True, stdout=subprocess.PIPE).stdout.decode().strip() + "/include"

# Clean the build directory to start fresh
build_dir = os.path.join(os.getcwd(), "build")
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.makedirs(build_dir)

run_command(f"cmake -S . -B build -Dalpaka_ACC_GPU_CUDA_ENABLE=ON -Dalpaka_ACC_GPU_CUDA_ONLY_MODE=ON -Dalpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE=OFF -Dalpaka_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DBoost_INCLUDE_DIR={boost_path}")
run_command(f"cmake --build build --target babelstream -j {num_cores}")
os.chdir("..")
Expand All @@ -68,15 +76,30 @@ def build_babelstream_rocm():
num_cores = max(1, multiprocessing.cpu_count() - 2)
os.chdir("alpaka")
boost_path = subprocess.run("spack location -i /u3oct6d", shell=True, stdout=subprocess.PIPE).stdout.decode().strip() + "/include"
run_command(f"cmake -S . -B build -Dalpaka_ACC_GPU_HIP_ENABLE=ON -Dalpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE=OFF -Dalpaka_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DBoost_INCLUDE_DIR={boost_path}")

# Clean the build directory to start fresh
build_dir = os.path.join(os.getcwd(), "build")
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.makedirs(build_dir)

run_command(f"cmake -S . -B build -Dalpaka_ACC_GPU_HIP_ENABLE=ON -Dalpaka_ACC_GPU_HIP_ONLY_MODE=ON -Dalpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE=OFF -Dalpaka_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DBoost_INCLUDE_DIR={boost_path}")
run_command(f"cmake --build build --target babelstream -j {num_cores}")
os.chdir("..")


def build_babelstream_sycl():
""" Build the BabelStream benchmark for Intel SYCL backend """
num_cores = max(1, multiprocessing.cpu_count() - 2)
os.chdir("alpaka")
boost_path = subprocess.run("spack location -i /u3oct6d", shell=True, stdout=subprocess.PIPE).stdout.decode().strip() + "/include"

# Clean the build directory to start fresh
build_dir = os.path.join(os.getcwd(), "build")
if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.makedirs(build_dir)

run_command(f"cmake -S . -B build -Dalpaka_ACC_SYCL_ENABLE=ON -Dalpaka_ACC_CPU_B_SEQ_T_SEQ_ENABLE=OFF -Dalpaka_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DBoost_INCLUDE_DIR={boost_path}")
run_command(f"cmake --build build --target babelstream -j {num_cores}")
os.chdir("..")
Expand All @@ -87,8 +110,8 @@ def run_babelstream():
current_datetime = datetime_now.strftime("%Y%m%d%H%M%S")
os.chdir("alpaka/build/benchmarks/babelstream")
filename = f"{current_datetime}-babelstream-output.txt"
run_command(f"./babelstream --array-size=33554432 --number-runs=100 > {filename}")
os.chdir("../../../../..")
run_command(f"./babelstream --array-size=33554432 --number-runs=100 > ../../../../{filename}")
os.chdir("../../../..")
print(f"Results saved to {filename}")

if __name__ == "__main__":
Expand All @@ -103,3 +126,4 @@ def run_babelstream():
else:
print("Environment setup failed. Please check the errors and try again.")


0 comments on commit c54d776

Please sign in to comment.