Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0fb2a71
[DFT] Initial DFT work & MKLGPU backend
hjabird Dec 29, 2022
79f2110
initial commit
anantsrivastava30 Dec 29, 2022
09e148d
[DFT] Initial DFT work & MKLGPU backend
hjabird Dec 29, 2022
9273511
Revert unnecessary CMake change in tests
hjabird Dec 30, 2022
3715cf2
Remove dft::mklgpu:: interface
hjabird Jan 6, 2023
56b751d
Update Copyright dates
hjabird Jan 11, 2023
24b7513
Replace partial specialization with if constexpr
hjabird Jan 11, 2023
4422b90
Remove macros from backend_XX_instantiations
hjabird Jan 11, 2023
c1a9845
Use default copy constructor
hjabird Jan 11, 2023
ceb4f6e
Make OpenCL required in example
hjabird Jan 11, 2023
8907ca3
Print banner uses single string
hjabird Jan 11, 2023
6307446
Add DFT & MKLGPU to support tables
hjabird Jan 13, 2023
9c2ebb5
Add missing header for va_arg
hjabird Jan 13, 2023
ef81d21
Duplicate main interface within backend libraries
hjabird Jan 24, 2023
9b0b1c8
initial mklcpu backend
anantsrivastava30 Jan 26, 2023
44b5cf2
wrap the descriptor in a buffer
anantsrivastava30 Jan 30, 2023
b3228b7
buffer inplace compute
anantsrivastava30 Jan 31, 2023
ae0dc22
update docs and remove unneeded dependency from dft example
FMarno Feb 1, 2023
00e3eeb
rest of the usm/buffer impl
anantsrivastava30 Feb 1, 2023
07ee8f8
commit checks
anantsrivastava30 Feb 1, 2023
c39c78c
backward impl
anantsrivastava30 Feb 1, 2023
92b7fa1
enabled real-complex out-of-place dft transforms
FMarno Feb 2, 2023
9c54762
initial commit
anantsrivastava30 Dec 29, 2022
5f9f21e
initial mklcpu backend
anantsrivastava30 Jan 26, 2023
cf743fa
wrap the descriptor in a buffer
anantsrivastava30 Jan 30, 2023
7781c74
buffer inplace compute
anantsrivastava30 Jan 31, 2023
1b4b449
rest of the usm/buffer impl
anantsrivastava30 Feb 1, 2023
94cb243
commit checks
anantsrivastava30 Feb 1, 2023
d510d33
backward impl
anantsrivastava30 Feb 1, 2023
891a9e6
Merge branch 'FFT_MKLCPU_backned' of https://github.com/anantsrivasta…
anantsrivastava30 Feb 6, 2023
eefabf6
[DFT] fix unit tests errors
anantsrivastava30 Feb 8, 2023
cf41bb9
clean debug msg
anantsrivastava30 Feb 8, 2023
bb3effa
debug real_real cpu
anantsrivastava30 Feb 24, 2023
d4197b7
rebase unit tests
anantsrivastava30 Feb 24, 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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ if(ENABLE_MKLCPU_BACKEND
OR ENABLE_ROCRAND_BACKEND)
list(APPEND DOMAINS_LIST "rng")
endif()
if(ENABLE_MKLGPU_BACKEND
OR ENABLE_MKLCPU_BACKEND)
list(APPEND DOMAINS_LIST "dft")
endif()

# Define required CXX compilers before project
if(CMAKE_CXX_COMPILER OR NOT ONEMKL_SYCL_IMPLEMENTATION STREQUAL "dpc++")
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ Supported domains: BLAS, LAPACK, RNG
<td align="center">Dynamic, Static</td>
<td align="center">LLVM*, hipSYCL</td>
</tr>
<tr>
<td rowspan=1 align="center">DFT</td>
<td align="center">Intel GPU</td>
<td rowspan=1 align="center">Intel(R) oneAPI Math Kernel Library</td>
<td align="center">Dynamic, Static</td>
<td align="center">DPC++</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -281,6 +288,13 @@ Supported domains: BLAS, LAPACK, RNG
<td align="center">Dynamic, Static</td>
<td align="center">DPC++</td>
</tr>
<tr>
<td rowspan=1 align="center">DFT</td>
<td align="center">Intel GPU</td>
<td rowspan=1 align="center">Intel(R) oneAPI Math Kernel Library</td>
<td align="center">Dynamic, Static</td>
<td align="center">DPC++</td>
</tr>
</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion docs/building_the_project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ CMake.
- False
* - target_domains (list)
- TARGET_DOMAINS (list)
- blas, lapack, rng
- blas, lapack, rng, dft
- All domains

.. note::
Expand Down
61 changes: 59 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ oneAPI Math Kernel Library (oneMKL) Interfaces offers examples with the followin
- blas: level3/gemm_usm
- rng: uniform_usm
- lapack: getrs_usm
- dft: complex_fwd_buffer, real_fwd_usm

Each routine has one run-time dispatching example and one compile-time dispatching example (which uses both mklcpu and cuda backends), located in `example/<$domain>/run_time_dispatching` and `example/<$domain>/compile_time_dispatching` subfolders, respectively.

To build examples, use cmake build option `-DBUILD_EXAMPLES=true`.
Compile_time_dispatching will be built if `-DBUILD_EXAMPLES=true` and cuda backend is enabled, because the compile-time dispatching example runs on both mklcpu and cuda backends.
Run_time_dispatching will be built if `-DBUILD_EXAMPLES=true` and `-DBUILD_SHARED_LIBS=true`
Run_time_dispatching will be built if `-DBUILD_EXAMPLES=true` and `-DBUILD_SHARED_LIBS=true`.
All DFT examples require the mklgpu backend to be enabled.

The example executable naming convention follows `example_<$domain>_<$routine>_<$backend>` for compile-time dispatching examples
or `example_<$domain>_<$routine>` for run-time dispatching examples.
E.g. `example_blas_gemm_usm_mklcpu_cublas ` `example_blas_gemm_usm`

## Example outputs (blas, rng, lapack)
## Example outputs (blas, rng, lapack, dft)

## blas

Expand Down Expand Up @@ -349,3 +351,58 @@ Random number generator example with uniform distribution ran OK on MKLCPU and C

```

## dft

Compile-time dispatching example with mklgpu backend

```none
$ SYCL_DEVICE_FILTER=gpu ./bin/example_dft_complex_fwd_buffer_mklgpu

########################################################################
# Complex out-of-place forward transform for Buffer API's example:
#
# Using APIs:
# Compile-time dispatch API
# Buffer forward complex out-of-place
#
# Using single precision (float) data type
#
# For Intel GPU with Intel MKLGPU backend.
#
# The environment variable SYCL_DEVICE_FILTER can be used to specify
# SYCL device
########################################################################

Running DFT Complex forward out-of-place buffer example
Using compile-time dispatch API with MKLGPU.
Running with single precision real data type on:
GPU device :Intel(R) UHD Graphics 750 [0x4c8a]
DFT Complex USM example ran OK on MKLGPU
```

Runtime dispatching example with both mklgpu backend

```none
SYCL_DEVICE_FILTER=gpu ./bin/example_dft_complex_fwd_buffer_mklgpu

########################################################################
# Complex out-of-place forward transform for Buffer API's example:
#
# Using APIs:
# Compile-time dispatch API
# Buffer forward complex out-of-place
#
# Using single precision (float) data type
#
# For Intel GPU with Intel MKLGPU backend.
#
# The environment variable SYCL_DEVICE_FILTER can be used to specify
# SYCL device
########################################################################

Running DFT Complex forward out-of-place buffer example
Using compile-time dispatch API with MKLGPU.
Running with single precision real data type on:
GPU device :Intel(R) UHD Graphics 750 [0x4c8a]
DFT Complex USM example ran OK on MKLGPU
```
25 changes: 25 additions & 0 deletions examples/dft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#===============================================================================
# Copyright 2023 Intel Corporation
#
# 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
#===============================================================================

add_subdirectory(compile_time_dispatching)

# runtime compilation is only possible with dynamic libraries
if (BUILD_SHARED_LIBS)
add_subdirectory(run_time_dispatching)
endif()
43 changes: 43 additions & 0 deletions examples/dft/compile_time_dispatching/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#===============================================================================
# Copyright 2023 Intel Corporation
#
# 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
#===============================================================================

#Build object from all sources
set(DFTI_CT_SOURCES "")
if(ENABLE_MKLCPU_BACKEND)
list(APPEND DFTI_CT_SOURCES "complex_fwd_buffer_mklgpu")
endif()

foreach(dfti_ct_sources ${DFTI_CT_SOURCES})
add_executable(example_${domain}_${dfti_ct_sources} ${dfti_ct_sources}.cpp)
target_include_directories(example_${domain}_${dfti_ct_sources}
PUBLIC ${PROJECT_SOURCE_DIR}/examples/include
PUBLIC ${PROJECT_SOURCE_DIR}/include
PUBLIC ${CMAKE_BINARY_DIR}/bin
)
if(domain STREQUAL "dft" AND ENABLE_MKLGPU_BACKEND)
add_dependencies(example_${domain}_${dfti_ct_sources} onemkl_${domain}_mklgpu)
list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_mklgpu)
endif()
target_link_libraries(example_${domain}_${dfti_ct_sources} PUBLIC
${ONEMKL_LIBRARIES_${domain}}
ONEMKL::SYCL::SYCL
)
# Register example as ctest
add_test(NAME ${domain}/EXAMPLE/CT/${dfti_ct_sources} COMMAND example_${domain}_${dfti_ct_sources})
endforeach(dfti_ct_sources)
132 changes: 132 additions & 0 deletions examples/dft/compile_time_dispatching/complex_fwd_buffer_mklcpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*******************************************************************************
* Copyright 2023 Intel Corporation
*
* 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
*******************************************************************************/

// STL includes
#include <iostream>

// oneMKL/SYCL includes
#if __has_include(<sycl/sycl.hpp>)
#include <sycl/sycl.hpp>
#else
#include <CL/sycl.hpp>
#endif
#include "oneapi/mkl.hpp"

void run_example(const sycl::device& cpu_device) {
constexpr int N = 10;

// Catch asynchronous exceptions for cpu
auto cpu_error_handler = [&](sycl::exception_list exceptions) {
for (auto const& e : exceptions) {
try {
std::rethrow_exception(e);
}
catch (sycl::exception const& e) {
// Handle not dft related exceptions that happened during asynchronous call
std::cerr << "Caught asynchronous SYCL exception:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
}
}
std::exit(2);
};

sycl::queue cpu_queue(cpu_device, cpu_error_handler);

std::vector<std::complex<float>> input_data(N);
std::vector<std::complex<float>> output_data(N);

// enabling
// 1. create descriptors
oneapi::mkl::dft::descriptor<oneapi::mkl::dft::precision::SINGLE,
oneapi::mkl::dft::domain::COMPLEX>
desc(N);

// 2. variadic set_value
desc.set_value(oneapi::mkl::dft::config_param::PLACEMENT,
oneapi::mkl::dft::config_value::NOT_INPLACE);
desc.set_value(oneapi::mkl::dft::config_param::NUMBER_OF_TRANSFORMS,
static_cast<std::int64_t>(1));

// 3. commit_descriptor (compile_time MKLcPU)
desc.commit(oneapi::mkl::backend_selector<oneapi::mkl::backend::mklcpu>{ cpu_queue });

// 4. compute_forward / compute_backward (MKLcPU)
{
sycl::buffer<std::complex<float>> input_buffer(input_data.data(), sycl::range<1>(N));
sycl::buffer<std::complex<float>> output_buffer(output_data.data(), sycl::range<1>(N));
oneapi::mkl::dft::compute_forward<decltype(desc), std::complex<float>, std::complex<float>>(
desc, input_buffer, output_buffer);
}
}

//
// Description of example setup, apis used and supported floating point type precisions
//
void print_example_banner() {
std::cout << "\n"
"########################################################################\n"
"# Complex out-of-place forward transform for Buffer API's example:\n"
"#\n"
"# Using APIs:\n"
"# Compile-time dispatch API\n"
"# Buffer forward complex out-of-place\n"
"#\n"
"# Using single precision (float) data type\n"
"#\n"
"# For Intel GPU with Intel MKLGPU backend.\n"
"#\n"
"# The environment variable SYCL_DEVICE_FILTER can be used to specify\n"
"#SYCL device\n"
"########################################################################\n"
<< std::endl;
}

//
// Main entry point for example.
//
int main(int argc, char** argv) {
print_example_banner();

try {
sycl::device cpu_device((sycl::cpu_selector_v));
std::cout << "Running DFT Complex forward out-of-place buffer example" << std::endl;
std::cout << "Using compile-time dispatch API with MKLcPU." << std::endl;
std::cout << "Running with single precision real data type on:" << std::endl;
std::cout << "\tcPU device :" << cpu_device.get_info<sycl::info::device::name>()
<< std::endl;

run_example(cpu_device);
std::cout << "DFT Complex USM example ran OK on MKLcPU" << std::endl;
}
catch (sycl::exception const& e) {
// Handle not dft related exceptions that happened during synchronous call
std::cerr << "Caught synchronous SYCL exception:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
std::cerr << "\tSYCL error code: " << e.code().value() << std::endl;
return 1;
}
catch (std::exception const& e) {
// Handle not SYCL related exceptions that happened during synchronous call
std::cerr << "Caught synchronous std::exception:" << std::endl;
std::cerr << "\t" << e.what() << std::endl;
return 1;
}

return 0;
}
Loading