File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Windows CPU OpenCL Benchmark
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches : [ main ]
7+
8+ jobs :
9+ benchmark :
10+ runs-on : windows-latest
11+
12+ steps :
13+ - name : Checkout Repository
14+ uses : actions/checkout@v4
15+
16+ # ---- Install OpenCL CPU runtime and build tools ----
17+ - name : Install OpenCL SDK and CMake
18+ run : |
19+ choco install opencl-sdk -y
20+ choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
21+
22+ - name : Install Python dependencies
23+ run : |
24+ pip install --upgrade pip
25+ pip install pyopencl numpy pandas matplotlib
26+
27+ # ---- Configure and build the C++ project ----
28+ - name : Configure project (CMake with MSVC)
29+ run : |
30+ cmake -S . -B build -G "Visual Studio 17 2022" -A x64
31+
32+ - name : Build Release
33+ run : |
34+ cmake --build build --config Release
35+
36+ # ---- Run your Python benchmark automation ----
37+ - name : Run Benchmark Script
38+ run : |
39+ python automation/benchmark.py 0
40+
41+ # ---- Upload benchmark results ----
42+ - name : Upload Results
43+ uses : actions/upload-artifact@v4
44+ with :
45+ name : windows-cpu-opencl-results
46+ path : automation/
Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.10 )
22project (opencl_bench)
33
4- set (CMAKE_CXX_STANDARD 17) # Use C++17
4+ set (CMAKE_CXX_STANDARD 17)
55set (CMAKE_CXX_STANDARD_REQUIRED ON )
66
7- set (OpenCL_INCLUDE_DIR "" )
8- set (OpenCL_LIBRARY "" )
9-
10-
11- include_directories (${OpenCL_INCLUDE_DIR} )
7+ # Let CMake find OpenCL automatically
8+ find_package (OpenCL REQUIRED )
129
1310add_executable (benchmark src/benchmark.cpp )
1411
15- target_link_libraries (benchmark ${OpenCL_LIBRARY} )
12+ # Include OpenCL headers
13+ target_include_directories (benchmark PRIVATE ${OpenCL_INCLUDE_DIRS} )
14+
15+ # Link OpenCL library
16+ target_link_libraries (benchmark PRIVATE ${OpenCL_LIBRARIES} )
Original file line number Diff line number Diff line change 66import pyopencl as cl
77import matplotlib .pyplot as plt
88import pandas as pd
9+ import platform
910
1011# Define path to the benchmark executable
1112SCRIPT_DIR = Path (__file__ ).parent .parent
12- BENCHMARK_EXECUTABLE = SCRIPT_DIR / "build" / "benchmark.exe"
1313SAVE_DIR = SCRIPT_DIR / "automation" / "benchmark_results.csv"
1414
15+ if platform .system () == "Windows" :
16+ BENCHMARK_EXECUTABLE = SCRIPT_DIR / "build" / "benchmark.exe"
17+ if not BENCHMARK_EXECUTABLE .exists ():
18+ BENCHMARK_EXECUTABLE = SCRIPT_DIR / "build" / "Release" / "benchmark.exe"
19+ else :
20+ BENCHMARK_EXECUTABLE = SCRIPT_DIR / "build" / "benchmark"
21+
1522
1623# Automatically detect all GPU devices
1724def get_gpu_devices ():
1825 platforms = cl .get_platforms ()
19- devices = [dev for p in platforms for dev in p .get_devices (device_type = cl .device_type .GPU )]
26+ devices = [dev for p in platforms for dev in p .get_devices (device_type = cl .device_type .ALL )]
2027
2128 for i , dev in enumerate (devices ):
2229 print (f"{ i } : { dev .name } " )
You can’t perform that action at this time.
0 commit comments