From 9584399142bf4c753bdef57e2a41fa66c788e24e Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 13:14:38 -0500 Subject: [PATCH 1/7] sycl: update for SYCL2020 spec Works with oneAPI 2023.2 release, openSYCL --- sycl/Makefile | 13 ++++++++++++- sycl/Simulation.cpp | 6 +++--- sycl/XSbench_header.h | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sycl/Makefile b/sycl/Makefile index 95ac06ac..d81516a6 100644 --- a/sycl/Makefile +++ b/sycl/Makefile @@ -29,7 +29,7 @@ obj = $(source:.cpp=.o) #=============================================================================== # Standard Flags -CFLAGS := -std=c++14 -Wall +CFLAGS := -std=c++17 -Wall # Linker Flags LDFLAGS = -lm @@ -48,6 +48,17 @@ ifeq ($(CC),llvm) LDFLAGS += -lOpenCL endif +# IntelOneAPI Compiler +ifeq ($(CC),oneapi) + CC = icpx + CFLAGS += -fsycl +endif + +ifeq ($(CC),opensycl) + CC = syclcc + CFLAGS += -fsycl +endif + # Debug Flags ifeq ($(DEBUG),yes) CFLAGS += -g diff --git a/sycl/Simulation.cpp b/sycl/Simulation.cpp index 1a882e0c..8d02c0e3 100644 --- a/sycl/Simulation.cpp +++ b/sycl/Simulation.cpp @@ -12,7 +12,7 @@ //////////////////////////////////////////////////////////////////////////////////// // use SYCL namespace to reduce symbol names -using namespace cl::sycl; +using namespace sycl; unsigned long long run_event_based_simulation(Inputs in, SimulationData SD, int mype, double * kernel_init_time) { @@ -51,7 +51,7 @@ unsigned long long run_event_based_simulation(Inputs in, SimulationData SD, int queue sycl_q{default_selector()}; //queue sycl_q{gpu_selector()}; //queue sycl_q{cpu_selector()}; - if(mype == 0 ) printf("Running on: %s\n", sycl_q.get_device().get_info().c_str()); + if(mype == 0 ) printf("Running on: %s\n", sycl_q.get_device().get_info().c_str()); if(mype == 0 ) printf("Initializing device buffers and JIT compiling kernel...\n"); //////////////////////////////////////////////////////////////////////////////// @@ -84,7 +84,7 @@ unsigned long long run_event_based_simulation(Inputs in, SimulationData SD, int // For the unionized grid, this is a large array. Enforce that it is able to be allocated on the // OpenCL device (as some OpenCL devices have fairly low limts here for some reason...) size_t index_grid_allocation_sz = ceil((SD.length_index_grid * sizeof(int))); - assert( index_grid_allocation_sz <= sycl_q.get_device().get_info() ); + assert( index_grid_allocation_sz <= sycl_q.get_device().get_info() ); buffer index_grid_d(SD.index_grid, (unsigned long long ) SD.length_index_grid); //////////////////////////////////////////////////////////////////////////////// diff --git a/sycl/XSbench_header.h b/sycl/XSbench_header.h index 8411dd62..8679d2dd 100644 --- a/sycl/XSbench_header.h +++ b/sycl/XSbench_header.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include // Papi Header #ifdef PAPI From 07c62fb9968ecd51e666410dcd7f963e08ec2371 Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 21:56:01 -0500 Subject: [PATCH 2/7] sycl make: allow CC to be specified in env, for ci --- sycl/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/Makefile b/sycl/Makefile index d81516a6..9632680b 100644 --- a/sycl/Makefile +++ b/sycl/Makefile @@ -2,11 +2,11 @@ # User Options #=============================================================================== -CC = llvm -OPTIMIZE = yes -DEBUG = no -PROFILE = no -MPI = no +CC ?= llvm +OPTIMIZE ?= yes +DEBUG ?= no +PROFILE ?= no +MPI ?= no #=============================================================================== # Program name & source code list From 72b1875201e02ff7192fc033e239b22b0502e6fc Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 22:04:06 -0500 Subject: [PATCH 3/7] sycl: use SYCL 2020 default selectors Note that for oneAPI, the ONEAPI_DEVICE_FILTER env var can be used to choose the device type, e.g. "opencl:cpu", or "gpu". This allows changing at runtime without having to recompile. Other SYCL implementations should have similar mechanisms. --- sycl/Simulation.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sycl/Simulation.cpp b/sycl/Simulation.cpp index 8d02c0e3..2c04f157 100644 --- a/sycl/Simulation.cpp +++ b/sycl/Simulation.cpp @@ -48,9 +48,7 @@ unsigned long long run_event_based_simulation(Inputs in, SimulationData SD, int { // create a queue using the default device for the platform (cpu, gpu) - queue sycl_q{default_selector()}; - //queue sycl_q{gpu_selector()}; - //queue sycl_q{cpu_selector()}; + queue sycl_q{default_selector_v}; if(mype == 0 ) printf("Running on: %s\n", sycl_q.get_device().get_info().c_str()); if(mype == 0 ) printf("Initializing device buffers and JIT compiling kernel...\n"); From d613fa1324678093ddee97a0af9dcf9808202747 Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 21:07:06 -0500 Subject: [PATCH 4/7] add github ci for sycl, cuda, hip, omp Runs on CPU when possible, build only for HIP and CUDA --- .github/workflows/cuda.yml | 19 +++++++++++++++++++ .github/workflows/hip.yml | 19 +++++++++++++++++++ .github/workflows/omp.yml | 27 +++++++++++++++++++++++++++ .github/workflows/sycl.yml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 .github/workflows/cuda.yml create mode 100644 .github/workflows/hip.yml create mode 100644 .github/workflows/omp.yml create mode 100644 .github/workflows/sycl.yml diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml new file mode 100644 index 00000000..2b518595 --- /dev/null +++ b/.github/workflows/cuda.yml @@ -0,0 +1,19 @@ +name: CUDA Tests + +on: + push: + branches: [ master, 'pr/*' ] + pull_request: + branches: [ master ] + +jobs: + build-cuda: + runs-on: ubuntu-latest + container: nvidia/cuda:11.0.3-devel-ubuntu20.04 + env: + DEBIAN_FRONTEND: noninteractive + BACKEND: cuda + steps: + - uses: actions/checkout@v3 + - name: make + run: cd $BACKEND; make -j4 diff --git a/.github/workflows/hip.yml b/.github/workflows/hip.yml new file mode 100644 index 00000000..1c8ff460 --- /dev/null +++ b/.github/workflows/hip.yml @@ -0,0 +1,19 @@ +name: HIP Tests + +on: + push: + branches: [ master, 'pr/*' ] + pull_request: + branches: [ master ] + +jobs: + build-hip: + runs-on: ubuntu-latest + container: rocm/dev-ubuntu-22.04:5.4.2-complete + env: + DEBIAN_FRONTEND: noninteractive + BACKEND: hip + steps: + - uses: actions/checkout@v3 + - name: make + run: cd $BACKEND; make -j4 diff --git a/.github/workflows/omp.yml b/.github/workflows/omp.yml new file mode 100644 index 00000000..e38b21ff --- /dev/null +++ b/.github/workflows/omp.yml @@ -0,0 +1,27 @@ +name: OMP Tests + +on: + push: + branches: [ master, 'pr/*' ] + pull_request: + branches: [ master ] + +jobs: + omp-run-cpu: + runs-on: ubuntu-latest + env: + DEBIAN_FRONTEND: noninteractive + CC: gcc + BACKEND: openmp-threading + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: make + run: cd $BACKEND; make -j4 + - name: run nuclide + run: ./$BACKEND/XSBench -m event -s small -G nuclide + - name: run hash + run: ./$BACKEND/XSBench -m event -s small -G hash + - name: run unionized + run: ./$BACKEND/XSBench -m event -s small -G unionized diff --git a/.github/workflows/sycl.yml b/.github/workflows/sycl.yml new file mode 100644 index 00000000..bee22d9e --- /dev/null +++ b/.github/workflows/sycl.yml @@ -0,0 +1,32 @@ +name: SYCL Tests + +on: + push: + branches: [ master, 'pr/*' ] + pull_request: + branches: [ master ] + +jobs: + sycl-oneapi-run-cpu: + runs-on: ubuntu-latest + container: intel/oneapi-basekit:2023.1.0-devel-ubuntu22.04 + env: + DEBIAN_FRONTEND: noninteractive + ONEAPI_DEVICE_SELECTOR: opencl:cpu + BACKEND: sycl + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: sycl-ls + run: | + which sycl-ls + sycl-ls + - name: make + run: cd $BACKEND; CC=oneapi make -j4 + - name: run nuclide + run: ./$BACKEND/XSBench -m event -s small -G nuclide + - name: run hash + run: ./$BACKEND/XSBench -m event -s small -G hash + - name: run unionized + run: ./$BACKEND/XSBench -m event -s small -G unionized From 8795193723307e638252e36a6350feed10d1c12c Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 21:45:36 -0500 Subject: [PATCH 5/7] ignore .o and XSBench binaries --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..08f0e1b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +*/XSBench From db090202a7d1a7f2a5d084df8f0a4b6031a3aad7 Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Thu, 13 Jul 2023 22:23:22 -0500 Subject: [PATCH 6/7] ci: add openmp-offload with oneAPI compiler --- .github/workflows/sycl.yml | 25 ++++++++++++++++--------- openmp-offload/Makefile | 10 +++++----- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/sycl.yml b/.github/workflows/sycl.yml index bee22d9e..5a71473a 100644 --- a/.github/workflows/sycl.yml +++ b/.github/workflows/sycl.yml @@ -13,7 +13,6 @@ jobs: env: DEBIAN_FRONTEND: noninteractive ONEAPI_DEVICE_SELECTOR: opencl:cpu - BACKEND: sycl steps: - uses: actions/checkout@v3 with: @@ -22,11 +21,19 @@ jobs: run: | which sycl-ls sycl-ls - - name: make - run: cd $BACKEND; CC=oneapi make -j4 - - name: run nuclide - run: ./$BACKEND/XSBench -m event -s small -G nuclide - - name: run hash - run: ./$BACKEND/XSBench -m event -s small -G hash - - name: run unionized - run: ./$BACKEND/XSBench -m event -s small -G unionized + - name: make sycl + run: cd sycl; CC=oneapi make -j4 + - name: run sycl nuclide + run: ./sycl/XSBench -m event -s small -G nuclide + - name: run sycl hash + run: ./sycl/XSBench -m event -s small -G hash + - name: run sycl unionized + run: ./sycl/XSBench -m event -s small -G unionized + - name: make openmp-offload + run: cd openmp-offload; COMPILER=intel make -j4 + - name: run openmp-offload nuclide + run: ./openmp-offload/XSBench -m event -s small -G nuclide + - name: run openmp-offload hash + run: ./openmp-offload/XSBench -m event -s small -G hash + - name: run openmp-offload unionized + run: ./openmp-offload/XSBench -m event -s small -G unionized diff --git a/openmp-offload/Makefile b/openmp-offload/Makefile index f3aae5ce..3c4166d3 100644 --- a/openmp-offload/Makefile +++ b/openmp-offload/Makefile @@ -2,11 +2,11 @@ # User Options #=============================================================================== -COMPILER = llvm -OPTIMIZE = yes -DEBUG = no -PROFILE = no -MPI = no +COMPILER ?= llvm +OPTIMIZE ?= yes +DEBUG ?= no +PROFILE ?= no +MPI ?= no #=============================================================================== # Program name & source code list From f3cf7329ab30801dbc2a587d6baa7baf5848f311 Mon Sep 17 00:00:00 2001 From: Bryce Allen Date: Fri, 14 Jul 2023 12:51:20 -0500 Subject: [PATCH 7/7] ci: add opencl build to oneapi ci Running fails with no useful error on github CI --- .github/workflows/{sycl.yml => oneapi.yml} | 6 ++++++ opencl/Makefile | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) rename .github/workflows/{sycl.yml => oneapi.yml} (81%) diff --git a/.github/workflows/sycl.yml b/.github/workflows/oneapi.yml similarity index 81% rename from .github/workflows/sycl.yml rename to .github/workflows/oneapi.yml index 5a71473a..e2473ffa 100644 --- a/.github/workflows/sycl.yml +++ b/.github/workflows/oneapi.yml @@ -37,3 +37,9 @@ jobs: run: ./openmp-offload/XSBench -m event -s small -G hash - name: run openmp-offload unionized run: ./openmp-offload/XSBench -m event -s small -G unionized + - name: install opencl packages + run: | + apt-get -y update && apt-get install -y --no-install-recommends intel-oneapi-runtime-opencl clinfo opencl-headers intel-opencl-icd + clinfo + - name: make opencl + run: cd opencl; COMPILER=gnu make -j4 diff --git a/opencl/Makefile b/opencl/Makefile index 9c5cb906..cdc49b0d 100644 --- a/opencl/Makefile +++ b/opencl/Makefile @@ -2,11 +2,11 @@ # User Options #=============================================================================== -COMPILER = gnu -OPTIMIZE = yes -DEBUG = no -PROFILE = no -MPI = no +COMPILER ?= gnu +OPTIMIZE ?= yes +DEBUG ?= no +PROFILE ?= no +MPI ?= no #=============================================================================== # Program name & source code list