Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync concurrency examples with development #737

Merged
merged 20 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2eae23b
Allow user to define the maximum number of kernel arguments and autom…
deukhyun-cha Nov 22, 2023
c42a185
Hotfix GitHub Actions
kris-rowe Nov 22, 2023
f92bf81
Remove dpcpp from modes tested with inline kernel example on GitHub (…
kris-rowe Nov 27, 2023
9e86ae7
Sets `OCCA_<MODE>_ENABLED` in CMake parent scope. (#720)
kris-rowe Nov 28, 2023
b0c3227
Correctly sync all streams in `device::finishAll()`. (#723)
kris-rowe Nov 30, 2023
5285d7b
Ensure all work is complete on device before freeing memory. (#724)
kris-rowe Nov 30, 2023
ff6e4ea
cmake: Small fix to prevent empty module path (#694)
AljenU Nov 30, 2023
3612b5d
Update cmake to generate kernel-arguments-related codes only if neces…
deukhyun-cha Dec 6, 2023
5226290
Fixes corruption of memory datatypes caused by short circuit logic in…
kris-rowe Dec 8, 2023
8957558
Refactor OpenCL mode and update CI testing (#730)
kris-rowe Dec 15, 2023
66ae951
Set SYCL subgroup size via kernel property or `@simd_length` attribut…
kris-rowe Dec 15, 2023
ce6f23c
**BREAKING** Make memory copies data type aware for consistency. (#728)
kris-rowe Dec 15, 2023
c17644b
**BREAKING** Return the number of `dtype` entries from `memory::size(…
kris-rowe Dec 15, 2023
7a364ea
Initial support for compiler attribute statements (#729)
noelchalmers Dec 15, 2023
7c2fe69
Prefix CMake build options with `OCCA` (#733)
kris-rowe Dec 18, 2023
495d314
Update year.
kris-rowe Dec 18, 2023
08db185
Update version number.
kris-rowe Dec 18, 2023
62ca3a9
Update minimum CMake version listed in docs.
kris-rowe Dec 20, 2023
ec9d90c
Rename `memcpy` free function length parameter to reflect changes to
kris-rowe Dec 20, 2023
6390b2d
Move `memoryPool` from `occa::experimental` to `occa` namespace
kris-rowe Dec 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
CC: icx
CXX: icpx
CXXFLAGS: -Wno-uninitialized
FC: ifx
OCCA_COVERAGE: 0
OCCA_FORTRAN_ENABLED: 1
useCMake: true
useoneAPI: true

Expand Down Expand Up @@ -113,9 +115,9 @@ jobs:
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_Fortran_COMPILER=${FC} \
-DENABLE_TESTS=ON \
-DENABLE_EXAMPLES=ON \
-DENABLE_FORTRAN=ON
-DOCCA_ENABLE_TESTS=ON \
-DOCCA_ENABLE_EXAMPLES=ON \
-DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED}

- name: CMake configure
if: ${{ matrix.useCMake && matrix.useoneAPI}}
Expand All @@ -129,9 +131,10 @@ jobs:
-DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX} \
-DENABLE_TESTS=ON \
-DENABLE_EXAMPLES=ON \
-DCMAKE_PREFIX_PATH="/opt/intel/oneapi/compiler/latest/linux;/opt/intel/oneapi/compiler/latest/linux/compiler"
-DCMAKE_Fortran_COMPILER=${FC} \
-DOCCA_ENABLE_TESTS=ON \
-DOCCA_ENABLE_EXAMPLES=ON \
-DOCCA_ENABLE_FORTRAN=${OCCA_FORTRAN_ENABLED}

- name: CMake build
if: ${{ matrix.useCMake && !matrix.useoneAPI}}
Expand Down Expand Up @@ -166,7 +169,7 @@ jobs:
- name: Run CTests
if: ${{ matrix.useCMake && !matrix.useoneAPI }}
run: |
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "examples_cpp_arrays-opencl|examples_cpp_for_loops-opencl|examples_cpp_generic_inline_kernel-opencl|examples_cpp_shared_memory-opencl|examples_cpp_nonblocking_streams-opencl|examples_cpp_for_loops-dpcpp|examples_cpp_arrays-dpcpp|examples_cpp_nonblocking_streams-dpcpp"
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "examples_cpp_arrays-opencl|examples_cpp_for_loops-opencl|examples_cpp_generic_inline_kernel-opencl|examples_cpp_shared_memory-opencl|examples_cpp_nonblocking_streams-opencl|examples_cpp_for_loops-dpcpp|examples_cpp_arrays-dpcpp|examples_cpp_generic_inline_kernel-dpcpp|examples_cpp_nonblocking_streams-dpcpp"



Expand All @@ -178,8 +181,8 @@ jobs:
OCCA_DPCPP_COMPILER: icpx
run: |
source /opt/intel/oneapi/setvars.sh
export SYCL_DEVICE_FILTER=opencl.cpu
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "examples_cpp_arrays-opencl|examples_cpp_for_loops-opencl|examples_cpp_generic_inline_kernel-opencl|examples_cpp_shared_memory-opencl|examples_cpp_nonblocking_streams-opencl|examples_cpp_for_loops-dpcpp|examples_cpp_arrays-dpcpp|examples_cpp_nonblocking_streams-dpcpp"
export ONEAPI_DEVICE_SELECTOR=*:cpu
ctest --test-dir build --progress --output-on-failure --parallel 8 --schedule-random -E "opencl-*|dpcpp-*"

- name: Upload code coverage
if: ${{ matrix.OCCA_COVERAGE }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ opt
/.compiledDefines
/include/occa/defines/compiledDefines.hpp
/include/occa/scripts
/include/occa/core/kernelOperators.hpp_codegen
/src/core/kernelOperators.cpp_codegen
/src/occa/internal/utils/runFunction.cpp_codegen
/include/occa/defines/macros.hpp_codegen

# Binaries generated to fetch compiler information
/scripts/compiler/compilerSupportsMPI
Expand Down
89 changes: 50 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.17 FATAL_ERROR)
cmake_minimum_required (VERSION 3.21 FATAL_ERROR)

#---[ CMake Config ]--------------------
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand All @@ -11,7 +11,7 @@ cmake_policy(SET CMP0056 NEW)

#---[ Build Config ]--------------------
project(OCCA
VERSION 1.6.0
VERSION 2.0.0
DESCRIPTION "JIT Compilation for Multiple Architectures: C++, OpenMP, CUDA, HIP, OpenCL, Metal"
HOMEPAGE_URL "https://github.com/libocca/occa"
LANGUAGES C CXX)
Expand All @@ -27,32 +27,34 @@ set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

option(ENABLE_OPENMP "Build with OpenMP if available" ON)
option(ENABLE_CUDA "Build with CUDA if available" ON)
option(ENABLE_OPENCL "Build with OpenCL if available" ON)
option(ENABLE_HIP "Build with HIP if available" ON)
option(ENABLE_METAL "Build with Metal if available" ON)
option(ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON)
option(OCCA_ENABLE_OPENMP "Build with OpenMP if available" ON)
option(OCCA_ENABLE_CUDA "Build with CUDA if available" ON)
option(OCCA_ENABLE_OPENCL "Build with OpenCL if available" ON)
option(OCCA_ENABLE_HIP "Build with HIP if available" ON)
option(OCCA_ENABLE_METAL "Build with Metal if available" ON)
option(OCCA_ENABLE_DPCPP "Build with SYCL/DPCPP if available" ON)

option(ENABLE_TESTS "Build tests" OFF)
option(ENABLE_EXAMPLES "Build simple examples" OFF)
option(ENABLE_FORTRAN "Enable Fortran interface" OFF)
option(OCCA_ENABLE_TESTS "Build tests" OFF)
option(OCCA_ENABLE_EXAMPLES "Build simple examples" OFF)
option(OCCA_ENABLE_FORTRAN "Enable Fortran interface" OFF)

if(ENABLE_FORTRAN)
if(OCCA_ENABLE_FORTRAN)
enable_language(Fortran)
endif()

option(ENABLE_SHARABLE_DEVICE "Enable sharable device by multiple threads" OFF)
if (ENABLE_SHARABLE_DEVICE)
add_compile_definitions(OCCA_THREAD_SHARABLE_ENABLED=1)
set(OCCA_THREAD_SHARABLE_ENABLED 1)
message("-- OCCA sharable by multi-threads : Enabled")
else()
add_compile_definitions(OCCA_THREAD_SHARABLE_ENABLED=0)
set(OCCA_THREAD_SHARABLE_ENABLED 0)
endif()

set(OCCA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(OCCA_BUILD_DIR ${CMAKE_BINARY_DIR})

include(CodeGen)

set(OCCA_USING_VS OFF)
set(OCCA_UNSAFE OFF)

Expand All @@ -78,11 +80,11 @@ message("-- System : ${CMAKE_SYSTEM}")
message("-- Build type : ${CMAKE_BUILD_TYPE}")
message("-- C flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
message("-- CXX flags : ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
if(ENABLE_FORTRAN)
if(OCCA_ENABLE_FORTRAN)
message("-- F90 flags : ${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
endif()

if(ENABLE_FORTRAN)
if(OCCA_ENABLE_FORTRAN)
set(CMAKE_Fortran_MODULE_DIRECTORY ${OCCA_BUILD_DIR}/mod)
endif()
#=======================================
Expand Down Expand Up @@ -114,7 +116,7 @@ target_compile_definitions(libocca PRIVATE -DUSE_CMAKE)
#=======================================

#---[ OpenMP ]--------------------------
if(ENABLE_OPENMP)
if(OCCA_ENABLE_OPENMP)
find_package(OpenMP)

if(OPENMP_CXX_FOUND)
Expand All @@ -126,14 +128,14 @@ if(ENABLE_OPENMP)
# Use the provided imported target OpenMP::OpenMP_CXX,
# (which wraps the CXX_INCLUDE_DIRS and CXX_LIBRARIES,) to make our package relocatable
target_link_libraries(libocca PRIVATE OpenMP::OpenMP_CXX)
else(OPENMP_CXX_FOUND)
else()
set(OCCA_OPENMP_ENABLED 0)
endif(OPENMP_CXX_FOUND)
endif(ENABLE_OPENMP)
endif()
endif()
#=======================================

#---[ CUDA ]----------------------------
if(ENABLE_CUDA)
if(OCCA_ENABLE_CUDA)
find_package(CUDAToolkit)

if(CUDAToolkit_FOUND)
Expand All @@ -144,15 +146,14 @@ if(ENABLE_CUDA)

# Use the provided imported target CUDA::cuda_driver, to make our package relocatable
target_link_libraries(libocca PRIVATE CUDA::cuda_driver)

else (CUDAToolkit_FOUND)
else()
set(OCCA_CUDA_ENABLED 0)
endif(CUDAToolkit_FOUND)
endif(ENABLE_CUDA)
endif()
endif()
#=======================================

#---[ OpenCL ]--------------------------
if(ENABLE_OPENCL)
if(OCCA_ENABLE_OPENCL)
find_package(OpenCLWrapper)

if(OpenCL_FOUND)
Expand All @@ -164,14 +165,14 @@ if(ENABLE_OPENCL)
# Use the provided imported target OpenCL::OpenCL,
# (which wraps the _INCLUDE_DIRS and _LIBRARIES,) to make our package relocatable
target_link_libraries(libocca PRIVATE OpenCL::OpenCL)
else (OpenCL_FOUND)
else()
set(OCCA_OPENCL_ENABLED 0)
endif(OpenCL_FOUND)
endif(ENABLE_OPENCL)
endif()
endif()
#=======================================

#---[ SYCL/DPCPP ]-----------------------
if(ENABLE_DPCPP)
if(OCCA_ENABLE_DPCPP)
find_package(DPCPP)

if(DPCPP_FOUND)
Expand All @@ -187,11 +188,11 @@ if(ENABLE_DPCPP)
else()
set(OCCA_DPCPP_ENABLED 0)
endif()
endif(ENABLE_DPCPP)
endif()
#=======================================

#---[ HIP ]-----------------------------
if(ENABLE_HIP)
if(OCCA_ENABLE_HIP)
find_package(HIP)

if(HIP_FOUND)
Expand All @@ -208,11 +209,11 @@ if(ENABLE_HIP)
else (HIP_FOUND)
set(OCCA_HIP_ENABLED 0)
endif(HIP_FOUND)
endif(ENABLE_HIP)
endif()
#=======================================

#---[ Metal ]---------------------------
if(ENABLE_METAL AND APPLE)
if(OCCA_ENABLE_METAL AND APPLE)
find_package(METAL)

if(METAL_FOUND)
Expand All @@ -230,6 +231,16 @@ if(ENABLE_METAL AND APPLE)
endif()
endif()
#=======================================

if(NOT OCCA_IS_TOP_LEVEL)
# OCCA is being built as a subdirectory in another project
set(OCCA_OPENMP_ENABLED ${OCCA_OPENMP_ENABLED} PARENT_SCOPE)
set(OCCA_CUDA_ENABLED ${OCCA_CUDA_ENABLED} PARENT_SCOPE)
set(OCCA_HIP_ENABLED ${OCCA_HIP_ENABLED} PARENT_SCOPE)
set(OCCA_DPCPP_ENABLED ${OCCA_DPCPP_ENABLED} PARENT_SCOPE)
set(OCCA_OPENCL_ENABLED ${OCCA_OPENCL_ENABLED} PARENT_SCOPE)
set(OCCA_METAL_ENABLED ${OCCA_METAL_ENABLED} PARENT_SCOPE)
endif()

# Generate CompiledDefines from libraries we found
configure_file(
Expand All @@ -245,7 +256,7 @@ file(
GLOB_RECURSE OCCA_SRC_cpp
RELATIVE ${OCCA_SOURCE_DIR} "src/*.cpp")

if(ENABLE_FORTRAN)
if(OCCA_ENABLE_FORTRAN)
file(GLOB_RECURSE OCCA_SRC_f90
RELATIVE ${OCCA_SOURCE_DIR} "src/*.f90")

Expand Down Expand Up @@ -275,14 +286,14 @@ target_sources(libocca PRIVATE ${OCCA_SRC})
install(TARGETS libocca EXPORT occaExport DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)

if(ENABLE_TESTS)
if(OCCA_ENABLE_TESTS)
include(CTest)
add_subdirectory(tests)
endif(ENABLE_TESTS)
endif()

if(ENABLE_EXAMPLES)
if(OCCA_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif(ENABLE_EXAMPLES)
endif()

add_subdirectory(bin)

Expand Down
22 changes: 11 additions & 11 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Minimum

- [CMake] v3.17 or newer
- [CMake] v3.21 or newer
- C++17 compiler
- C11 compiler

Expand All @@ -25,7 +25,7 @@ OCCA uses the [CMake] build system. For convenience, the shell script `configure

Example
```shell
$ CC=clang CXX=clang++ ENABLE_OPENMP="OFF" ./configure-cmake.sh
$ CC=clang CXX=clang++ OCCA_ENABLE_OPENMP="OFF" ./configure-cmake.sh
```

| Build Parameter | Description | Default |
Expand All @@ -37,15 +37,15 @@ $ CC=clang CXX=clang++ ENABLE_OPENMP="OFF" ./configure-cmake.sh
| CXXFLAGS | C++ compiler flags | *empty* |
| CC | C11 compiler| `gcc` |
| CFLAGS | C compiler flags | *empty* |
| ENABLE_CUDA | Enable use of the CUDA backend | `ON`|
| ENABLE_HIP | Enable use of the HIP backend | `ON`|
| ENABLE_DPCPP | Enable use of the DPC++ backend | `ON`|
| ENABLE_OPENCL | Enable use of the OpenCL backend | `ON`|
| ENABLE_OPENMP | Enable use of the OpenMP backend | `ON`|
| ENABLE_METAL | Enable use of the Metal backend | `ON`|
| ENABLE_TESTS | Build OCCA's test harness | `ON` |
| ENABLE_EXAMPLES | Build OCCA examples | `ON` |
| ENABLE_FORTRAN | Build the Fortran language bindings | `OFF`|
| OCCA_ENABLE_CUDA | Enable use of the CUDA backend | `ON`|
| OCCA_ENABLE_HIP | Enable use of the HIP backend | `ON`|
| OCCA_ENABLE_DPCPP | Enable use of the DPC++ backend | `ON`|
| OCCA_ENABLE_OPENCL | Enable use of the OpenCL backend | `ON`|
| OCCA_ENABLE_OPENMP | Enable use of the OpenMP backend | `ON`|
| OCCA_ENABLE_METAL | Enable use of the Metal backend | `ON`|
| OCCA_ENABLE_TESTS | Build OCCA's test harness | `ON` |
| OCCA_ENABLE_EXAMPLES | Build OCCA examples | `ON` |
| OCCA_ENABLE_FORTRAN | Build the Fortran language bindings | `OFF`|
| FC | Fortran 90 compiler | `gfortran` |
| FFLAGS | Fortran compiler flags | *empty* |

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2023 David Medina and Tim Warburton
Copyright (c) 2014-2024 David Medina and Tim Warburton

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ else
endif
#=================================================

PLACE_GENERATED_CODES := $(shell mkdir -p $(OCCA_DIR)/include/occa/core/codegen | \
mkdir -p $(OCCA_DIR)/src/core/codegen | \
mkdir -p $(OCCA_DIR)/src/occa/internal/utils/codegen | \
mkdir -p $(OCCA_DIR)/include/occa/defines/codegen)
PLACE_GENERATED_CODES := $(shell cp $(OCCA_DIR)/scripts/codegen/kernelOperators.hpp_codegen.in $(OCCA_DIR)/include/occa/core/codegen/kernelOperators.hpp_codegen | \
cp $(OCCA_DIR)/scripts/codegen/kernelOperators.cpp_codegen.in $(OCCA_DIR)/src/core/codegen/kernelOperators.cpp_codegen | \
cp $(OCCA_DIR)/scripts/codegen/runFunction.cpp_codegen.in $(OCCA_DIR)/src/occa/internal/utils/codegen/runFunction.cpp_codegen | \
cp $(OCCA_DIR)/scripts/codegen/macros.hpp_codegen.in $(OCCA_DIR)/include/occa/defines/codegen/macros.hpp_codegen)

#---[ Compile Library ]---------------------------
# Setup compiled defines and force rebuild if defines changed
Expand All @@ -95,8 +103,9 @@ MAKE_COMPILED_DEFINES := $(shell cat "$(OCCA_DIR)/scripts/build/compiledDefinesT
s,@@OCCA_HIP_ENABLED@@,$(OCCA_HIP_ENABLED),g;\
s,@@OCCA_OPENCL_ENABLED@@,$(OCCA_OPENCL_ENABLED),g;\
s,@@OCCA_METAL_ENABLED@@,$(OCCA_METAL_ENABLED),g;\
s,@@OCCA_DPCPP_ENABLED@@,$(OCCA_DPCPP_ENABLED),g;\
s,@@OCCA_DPCPP_ENABLED@@,$(OCCA_DPCPP_ENABLED),g;\
s,@@OCCA_THREAD_SHARABLE_ENABLED@@,$(OCCA_THREAD_SHARABLE_ENABLED),g;\
s,@@OCCA_MAX_ARGS@@,$(OCCA_MAX_ARGS),g;\
s,@@OCCA_BUILD_DIR@@,$(OCCA_BUILD_DIR),g;"\
> "$(NEW_COMPILED_DEFINES)")

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Mission critical computational science and engineering applications from the pub

### Minimum

- [CMake] v3.17 or newer
- [CMake] v3.21 or newer
- C++17 compiler
- C11 compiler

Expand All @@ -59,7 +59,7 @@ For convenience, the shell script `configure-cmake.sh` has been provided to driv

The following demonstrates a typical sequence of shell commands to build, test, and install occa:
```shell
$ ./configure.sh
$ ./configure-cmake.sh
$ cmake --build build --parallel <number-of-threads>
$ ctest --test-dir build --output-on-failure
$ cmake --install build --prefix install
Expand Down
Loading