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

[DFT] Add rocFFT backend for DFT interface #330

Merged
merged 10 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ option(ENABLE_ROCSOLVER_BACKEND "Enable the rocSOLVER backend for the LAPACK int

# dft
option(ENABLE_CUFFT_BACKEND "Enable the cuFFT backend for the DFT interface" OFF)
option(ENABLE_ROCFFT_BACKEND "Enable the rocFFT backend for the DFT interface" OFF)


set(ONEMKL_SYCL_IMPLEMENTATION "dpc++" CACHE STRING "Name of the SYCL compiler")
Expand Down Expand Up @@ -100,7 +101,8 @@ if(ENABLE_MKLCPU_BACKEND
endif()
if(ENABLE_MKLGPU_BACKEND
OR ENABLE_MKLCPU_BACKEND
OR ENABLE_CUFFT_BACKEND)
OR ENABLE_CUFFT_BACKEND
OR ENABLE_ROCFFT_BACKEND)
list(APPEND DOMAINS_LIST "dft")
endif()

Expand All @@ -119,8 +121,8 @@ if(CMAKE_CXX_COMPILER OR NOT ONEMKL_SYCL_IMPLEMENTATION STREQUAL "dpc++")
string(REPLACE "\\" "/" CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER})
endif()
else()
if(ENABLE_CUBLAS_BACKEND OR ENABLE_CURAND_BACKEND OR ENABLE_CUFFT_BACKEND
OR ENABLE_ROCBLAS_BACKEND OR ENABLE_ROCRAND_BACKEND OR ENABLE_ROCSOLVER_BACKEND)
if(ENABLE_CUBLAS_BACKEND OR ENABLE_CURAND_BACKEND OR ENABLE_CUSOLVER_BACKEND OR ENABLE_CUFFT_BACKEND
OR ENABLE_ROCBLAS_BACKEND OR ENABLE_ROCRAND_BACKEND OR ENABLE_ROCSOLVER_BACKEND OR ENABLE_ROCFFT_BACKEND)
set(CMAKE_CXX_COMPILER "clang++")
elseif(ENABLE_MKLGPU_BACKEND)
if(UNIX)
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ oneMKL is part of [oneAPI](https://oneapi.io).
</thead>
<tbody>
<tr>
<td rowspan=11 align="center">oneMKL interface</td>
<td rowspan=11 align="center">oneMKL selector</td>
<td rowspan=12 align="center">oneMKL interface</td>
<td rowspan=12 align="center">oneMKL selector</td>
<td align="center"><a href="https://software.intel.com/en-us/oneapi/onemkl">Intel(R) oneAPI Math Kernel Library</a> for x86 CPU</td>
<td align="center">x86 CPU</td>
</tr>
Expand Down Expand Up @@ -59,6 +59,10 @@ oneMKL is part of [oneAPI](https://oneapi.io).
<td align="center"><a href="https://github.com/ROCmSoftwarePlatform/rocRAND"> AMD rocRAND</a> for AMD GPU </td>
<td align="center">AMD GPU</td>
</tr>
<tr>
<td align="center"><a href="https://github.com/ROCmSoftwarePlatform/rocFFT">AMD rocFFT</a> for AMD GPU </td>
<td align="center">AMD GPU</td>
</tr>
<tr>
<td align="center"><a href="https://github.com/codeplaysoftware/sycl-blas"> SYCL-BLAS </a></td>
<td align="center">x86 CPU, Intel GPU, NVIDIA GPU, AMD GPU</td>
Expand Down Expand Up @@ -238,7 +242,7 @@ Supported domains: BLAS, LAPACK, RNG, DFT
<td align="center">LLVM*, hipSYCL</td>
</tr>
<tr>
<td rowspan=3 align="center">DFT</td>
<td rowspan=4 align="center">DFT</td>
<td align="center">Intel GPU</td>
<td rowspan=2 align="center">Intel(R) oneAPI Math Kernel Library</td>
<td align="center">Dynamic, Static</td>
Expand All @@ -255,6 +259,12 @@ Supported domains: BLAS, LAPACK, RNG, DFT
<td align="center">Dynamic, Static</td>
<td align="center">DPC++</td>
</tr>
<tr>
<td align="center">AMD GPU</td>
<td align="center">AMD rocFFT</td>
<td align="center">Dynamic, Static</td>
<td align="center">DPC++</td>
</tr>
Rbiessy marked this conversation as resolved.
Show resolved Hide resolved
</tbody>
</table>

Expand Down Expand Up @@ -464,6 +474,7 @@ Python | 3.6 or higher | No | *N/A* | *Pre-installed or Installed by user* | [PS
[AMD rocBLAS](https://rocblas.readthedocs.io/en/rocm-4.5.2/) | 4.5 | No | *N/A* | *Installed by user* |[AMD License](https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/LICENSE.md)
[AMD rocRAND](https://github.com/ROCmSoftwarePlatform/rocRAND) | 5.1.0 | No | *N/A* | *Installed by user* |[AMD License](https://github.com/ROCmSoftwarePlatform/rocRAND/blob/develop/LICENSE.txt)
[AMD rocSOLVER](https://github.com/ROCmSoftwarePlatform/rocSOLVER) | 5.0.0 | No | *N/A* | *Installed by user* |[AMD License](https://github.com/ROCmSoftwarePlatform/rocRAND/blob/develop/LICENSE.txt)
[AMD rocFFT](https://github.com/ROCmSoftwarePlatform/rocFFT) | rocm-5.4.3 | No | *N/A* | *Installed by user* |[AMD License](https://github.com/ROCmSoftwarePlatform/rocFFT/blob/rocm-5.4.3/LICENSE.md)
[NETLIB LAPACK](https://www.netlib.org/) | 3.7.1 | Yes | conan-community | ~/.conan/data or $CONAN_USER_HOME/.conan/data | [BSD like license](http://www.netlib.org/lapack/LICENSE.txt)
[Sphinx](https://www.sphinx-doc.org/en/master/) | 2.4.4 | Yes | pip | ~/.local/bin (or similar user local directory) | [BSD License](https://github.com/sphinx-doc/sphinx/blob/3.x/LICENSE)
[SYCL-BLAS](https://github.com/codeplaysoftware/sycl-blas) | 0.1 | No | *N/A* | *Installed by user* | [Apache License v2.0](https://github.com/codeplaysoftware/sycl-blas/blob/master/LICENSE)
Expand Down
27 changes: 26 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ Running with single precision real data type on:
DFT Complex USM example ran OK on MKLGPU
```

Runtime dispatching example with both MKLGPU and cuFFT backend
Runtime dispatching example with MKLGPU, cuFFT, and rocFFT backends:

```none
SYCL_DEVICE_FILTER=gpu ./bin/example_dft_real_fwd_usm
Expand Down Expand Up @@ -431,3 +431,28 @@ Running with single precision real data type:
DFT example run_time dispatch
DFT example ran OK
```

```none
./bin/example_dft_real_fwd_usm

########################################################################
# DFTI complex in-place forward transform with USM API example:
#
# Using APIs:
# USM forward complex in-place
# Run-time dispatch
#
# Using single precision (float) data type
#
# Device will be selected during runtime.
# The environment variable SYCL_DEVICE_FILTER can be used to specify
# SYCL device
#
########################################################################

Running DFT complex forward example on GPU device
Device name is: AMD Radeon PRO W6800
Running with single precision real data type:
DFT example run_time dispatch
DFT example ran OK
```
11 changes: 4 additions & 7 deletions examples/dft/run_time_dispatching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@
#===============================================================================

# NOTE: user needs to set env var SYCL_DEVICE_FILTER to use runtime example (no need to specify backend when building with CMake)
include(WarningsUtils)


# Build object from all example sources
set(DFT_RT_SOURCES "")
if(ENABLE_MKLGPU_BACKEND OR ENABLE_CUFFT_BACKEND)
list(APPEND DFT_RT_SOURCES "real_fwd_usm")
endif()

include(WarningsUtils)

# Set up for the right backend for run-time dispatching examples
# If users build more than one backend (i.e. mklcpu and mklgpu, or mklcpu and CUDA), they may need to
# overwrite SYCL_DEVICE_FILTER in their environment to run on the desired backend
set(DEVICE_FILTERS "")
if(ENABLE_MKLGPU_BACKEND OR ENABLE_CUFFT_BACKEND)
if(ENABLE_MKLGPU_BACKEND OR ENABLE_CUFFT_BACKEND OR ENABLE_ROCFFT_BACKEND)
list(APPEND DFT_RT_SOURCES "real_fwd_usm")
list(APPEND DEVICE_FILTERS "gpu")
endif()

Expand Down
22 changes: 14 additions & 8 deletions include/oneapi/mkl/detail/backends.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,25 @@ enum class backend {
rocrand,
syclblas,
cufft,
rocfft,
unsupported
};

typedef std::map<backend, std::string> backendmap;

static backendmap backend_map = {
{ backend::mklcpu, "mklcpu" }, { backend::mklgpu, "mklgpu" },
{ backend::cublas, "cublas" }, { backend::cusolver, "cusolver" },
{ backend::curand, "curand" }, { backend::netlib, "netlib" },
{ backend::rocblas, "rocblas" }, { backend::rocrand, "rocrand" },
{ backend::rocsolver, "rocsolver" }, { backend::syclblas, "syclblas" },
{ backend::cufft, "cufft" }, { backend::unsupported, "unsupported" }
};
static backendmap backend_map = { { backend::mklcpu, "mklcpu" },
{ backend::mklgpu, "mklgpu" },
{ backend::cublas, "cublas" },
{ backend::cusolver, "cusolver" },
{ backend::curand, "curand" },
{ backend::netlib, "netlib" },
{ backend::rocblas, "rocblas" },
{ backend::rocrand, "rocrand" },
{ backend::rocsolver, "rocsolver" },
{ backend::syclblas, "syclblas" },
{ backend::cufft, "cufft" },
{ backend::rocfft, "rocfft" },
{ backend::unsupported, "unsupported" } };

} //namespace mkl
} //namespace oneapi
Expand Down
6 changes: 6 additions & 0 deletions include/oneapi/mkl/detail/backends_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ static std::map<domain, std::map<device, std::vector<const char*>>> libraries =
{
#ifdef ENABLE_MKLGPU_BACKEND
LIB_NAME("dft_mklgpu")
#endif
} },
{ device::amdgpu,
{
#ifdef ENABLE_ROCFFT_BACKEND
LIB_NAME("dft_rocfft"),
#endif
} },
{ device::nvidiagpu,
Expand Down
4 changes: 4 additions & 0 deletions include/oneapi/mkl/dft/detail/descriptor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class descriptor {
void commit(backend_selector<backend::cufft> selector);
#endif

#ifdef ENABLE_ROCFFT_BACKEND
void commit(backend_selector<backend::rocfft> selector);
#endif

const dft_values<prec, dom>& get_values() const noexcept {
return values_;
};
Expand Down
49 changes: 49 additions & 0 deletions include/oneapi/mkl/dft/detail/rocfft/onemkl_dft_rocfft.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright Codeplay Software Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/

#ifndef _ONEMKL_DFT_ROCFFT_HPP_
#define _ONEMKL_DFT_ROCFFT_HPP_

#if __has_include(<sycl/sycl.hpp>)
#include <sycl/sycl.hpp>
#else
#include <CL/sycl.hpp>
#endif

#include "oneapi/mkl/detail/export.hpp"
#include "oneapi/mkl/dft/detail/types_impl.hpp"

namespace oneapi::mkl::dft {

namespace detail {
// Forward declarations
template <precision prec, domain dom>
class commit_impl;

template <precision prec, domain dom>
class descriptor;
} // namespace detail

namespace rocfft {
#include "oneapi/mkl/dft/detail/dft_ct.hxx"
} // namespace rocfft

} // namespace oneapi::mkl::dft

#endif // _ONEMKL_DFT_ROCFFT_HPP_
11 changes: 6 additions & 5 deletions src/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
#define ONEMKL_CONFIG_H

#cmakedefine ENABLE_CUBLAS_BACKEND
#cmakedefine ENABLE_CUSOLVER_BACKEND
#cmakedefine ENABLE_CUFFT_BACKEND
#cmakedefine ENABLE_ROCBLAS_BACKEND
#cmakedefine ENABLE_ROCRAND_BACKEND
#cmakedefine ENABLE_ROCSOLVER_BACKEND
#cmakedefine ENABLE_CURAND_BACKEND
#cmakedefine ENABLE_CUSOLVER_BACKEND
#cmakedefine ENABLE_MKLCPU_BACKEND
#cmakedefine ENABLE_MKLGPU_BACKEND
#cmakedefine ENABLE_NETLIB_BACKEND
#cmakedefine ENABLE_ROCBLAS_BACKEND
#cmakedefine ENABLE_ROCFFT_BACKEND
#cmakedefine ENABLE_ROCRAND_BACKEND
#cmakedefine ENABLE_ROCSOLVER_BACKEND
#cmakedefine ENABLE_SYCLBLAS_BACKEND
#cmakedefine ENABLE_SYCLBLAS_BACKEND_AMD_GPU
#cmakedefine ENABLE_SYCLBLAS_BACKEND_INTEL_CPU
#cmakedefine ENABLE_SYCLBLAS_BACKEND_INTEL_GPU
#cmakedefine ENABLE_SYCLBLAS_BACKEND_AMD_GPU
#cmakedefine ENABLE_SYCLBLAS_BACKEND_NVIDIA_GPU
#cmakedefine BUILD_SHARED_LIBS
#cmakedefine REF_BLAS_LIBNAME "@REF_BLAS_LIBNAME@"
hjabird marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 4 additions & 0 deletions src/dft/backends/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ endif()
if(ENABLE_CUFFT_BACKEND)
add_subdirectory(cufft)
endif()

if(ENABLE_ROCFFT_BACKEND)
add_subdirectory(rocfft)
endif()
76 changes: 76 additions & 0 deletions src/dft/backends/rocfft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#===============================================================================
# Copyright Codeplay Software Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
#
#
# SPDX-License-Identifier: Apache-2.0
#===============================================================================

set(LIB_NAME onemkl_dft_rocfft)
set(LIB_OBJ ${LIB_NAME}_obj)


add_library(${LIB_NAME})
add_library(${LIB_OBJ} OBJECT
descriptor.cpp
commit.cpp
forward.cpp
backward.cpp
compute_signature.cpp
$<$<BOOL:${BUILD_SHARED_LIBS}>: mkl_dft_rocfft_wrappers.cpp>
)

target_include_directories(${LIB_OBJ}
PRIVATE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/bin
${MKL_INCLUDE}
)

target_compile_options(${LIB_OBJ} PRIVATE ${ONEMKL_BUILD_COPT} ${MKL_COPT})

find_package(HIP REQUIRED)
find_package(rocfft REQUIRED)

target_link_libraries(${LIB_OBJ} PRIVATE hip::host roc::rocfft)

target_link_libraries(${LIB_OBJ} PUBLIC ONEMKL::SYCL::SYCL ${MKL_LINK_SYCL})

set_target_properties(${LIB_OBJ} PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
target_link_libraries(${LIB_NAME} PUBLIC ${LIB_OBJ})

# Set oneMKL libraries as not transitive for dynamic
if(BUILD_SHARED_LIBS)
set_target_properties(${LIB_NAME} PROPERTIES
INTERFACE_LINK_LIBRARIES ONEMKL::SYCL::SYCL
)
endif()

# Add major version to the library
set_target_properties(${LIB_NAME} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
)

# Add dependencies rpath to the library
list(APPEND CMAKE_BUILD_RPATH $<TARGET_FILE_DIR:${LIB_NAME}>)

# Add the library to install package
install(TARGETS ${LIB_OBJ} EXPORT oneMKLTargets)
install(TARGETS ${LIB_NAME} EXPORT oneMKLTargets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
Loading