-
Notifications
You must be signed in to change notification settings - Fork 175
[DFT] Synced mklcpu backend + Real_Real tests #288
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
Merged
anantsrivastava30
merged 67 commits into
uxlfoundation:develop
from
anantsrivastava30:synced_mklcpu_backend
Apr 28, 2023
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
68a98b1
FFT_MKLCPU_staging + sync #261
anantsrivastava30 64cfbd1
fix real_real failures
anantsrivastava30 1150033
tests for CPU backend
anantsrivastava30 cb2655d
[DFT] fix rebase issues
anantsrivastava30 66a1aad
Merge branch 'develop' of https://github.com/oneapi-src/oneMKL into s…
anantsrivastava30 f09b61e
[DFT] address reviews
anantsrivastava30 9d08e22
address reviews
anantsrivastava30 9ca597a
sync w/ head
anantsrivastava30 04b0894
minor changes and error checks
anantsrivastava30 963670d
command group handles only the DftiCommitDescriptor
anantsrivastava30 27e8af5
move queue to pass by reference
anantsrivastava30 fbdf123
set the distance to true default
anantsrivastava30 08cdf26
fix testing issue with complex_complex
anantsrivastava30 36af25c
change real_real test to work for md, batch transforms
anantsrivastava30 1e725f2
adderssing minor comments
anantsrivastava30 2e14329
add error messages for ordering, transpose, workspace
anantsrivastava30 b56bf89
change error message from cpu to gpu
anantsrivastava30 9c560c4
move the desc_buffer to the commit class to avoid descructor invoke
anantsrivastava30 ae4ef45
refactor forward declared derived class
anantsrivastava30 7d8ab36
extend buffer lifetime for backward
anantsrivastava30 3c74bc3
add error messaging for compute
anantsrivastava30 f34cd13
clang-format
anantsrivastava30 c003254
address reviews
anantsrivastava30 40cabd8
patchfix for transform in/out distances to fwd/bwd
anantsrivastava30 113cb04
revert resetting dist in roundtrip
anantsrivastava30 eea2936
revert tests to match specs
anantsrivastava30 2da7ee6
clang-format
anantsrivastava30 06ee321
fix ct adding both backends to the linkline
anantsrivastava30 968c2cc
add line
anantsrivastava30 51bb1e8
FFT_MKLCPU_staging + sync #261
anantsrivastava30 464121a
fix real_real failures
anantsrivastava30 e97a40d
tests for CPU backend
anantsrivastava30 e3fb0b0
[DFT] fix rebase issues
anantsrivastava30 8c558ab
[DFT] address reviews
anantsrivastava30 e583b06
address reviews
anantsrivastava30 82a8ef8
minor changes and error checks
anantsrivastava30 cb619b2
command group handles only the DftiCommitDescriptor
anantsrivastava30 fb93b03
move queue to pass by reference
anantsrivastava30 4443718
set the distance to true default
anantsrivastava30 88fbaf7
fix testing issue with complex_complex
anantsrivastava30 d08713a
change real_real test to work for md, batch transforms
anantsrivastava30 8e42c85
adderssing minor comments
anantsrivastava30 822d7f6
add error messages for ordering, transpose, workspace
anantsrivastava30 19ba45d
change error message from cpu to gpu
anantsrivastava30 71472df
move the desc_buffer to the commit class to avoid descructor invoke
anantsrivastava30 27da795
refactor forward declared derived class
anantsrivastava30 5bfcab3
extend buffer lifetime for backward
anantsrivastava30 e0f5165
add error messaging for compute
anantsrivastava30 4313b42
clang-format
anantsrivastava30 735e843
address reviews
anantsrivastava30 5ac42ad
patchfix for transform in/out distances to fwd/bwd
anantsrivastava30 5bcb41c
revert resetting dist in roundtrip
anantsrivastava30 20f6913
revert tests to match specs
anantsrivastava30 859ff4b
clang-format
anantsrivastava30 b056587
fix ct adding both backends to the linkline
anantsrivastava30 728f6e2
add line
anantsrivastava30 8eb616f
Merge branch 'synced_mklcpu_backend' of https://github.com/anantsriva…
anantsrivastava30 86c1ec9
address reviews
anantsrivastava30 092ba93
move the derived class to its own file
anantsrivastava30 89edd4d
address warnings, and change buffer type
anantsrivastava30 0f0bac0
Update src/dft/backends/mklcpu/commit.cpp
anantsrivastava30 b690dad
resovle dynamic dispatch issue
anantsrivastava30 0463106
merge cmake for both device
anantsrivastava30 a118caf
remove bad file
anantsrivastava30 826bb63
removed old comment
anantsrivastava30 8f63032
Merge branch 'develop' into synced_mklcpu_backend
anantsrivastava30 ba3146d
clang-format
anantsrivastava30 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,28 +19,45 @@ | |
|
|
||
| #Build object from all sources | ||
| set(DFTI_CT_SOURCES "") | ||
|
|
||
| if(ENABLE_MKLGPU_BACKEND) | ||
| list(APPEND DFTI_CT_SOURCES "complex_fwd_buffer_mklgpu") | ||
| endif() | ||
|
|
||
| if(ENABLE_MKLCPU_BACKEND) | ||
| list(APPEND DFTI_CT_SOURCES "complex_fwd_buffer_mklcpu") | ||
| endif() | ||
|
|
||
| include(WarningsUtils) | ||
|
|
||
| foreach(dfti_ct_sources ${DFTI_CT_SOURCES}) | ||
| add_executable(example_${domain}_${dfti_ct_sources} ${dfti_ct_sources}.cpp) | ||
| # add executable and define include directories | ||
| # add dependencies and link libraries | ||
| # register example as ctest | ||
| 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) | ||
|
|
||
| set(ONEMKL_LIBRARIES_${domain} "") | ||
| if(domain STREQUAL "dft") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is domain ever not dft? |
||
| if(dfti_ct_sources MATCHES "_mklcpu$") | ||
| add_dependencies(example_${domain}_${dfti_ct_sources} onemkl_${domain}_mklcpu) | ||
| list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_mklcpu) | ||
| endif() | ||
| if(dfti_ct_sources MATCHES "_mklgpu$") | ||
| add_dependencies(example_${domain}_${dfti_ct_sources} onemkl_${domain}_mklgpu) | ||
| list(APPEND ONEMKL_LIBRARIES_${domain} onemkl_${domain}_mklgpu) | ||
| endif() | ||
| endif() | ||
|
|
||
| target_link_libraries(example_${domain}_${dfti_ct_sources} | ||
| PUBLIC ${ONEMKL_LIBRARIES_${domain}} | ||
| PUBLIC ONEMKL::SYCL::SYCL | ||
| PRIVATE onemkl_warnings | ||
| ${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) | ||
| 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
132
examples/dft/compile_time_dispatching/complex_fwd_buffer_mklcpu.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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<double>> input_data(N); | ||
| std::vector<std::complex<double>> output_data(N); | ||
|
|
||
| // enabling | ||
| // 1. create descriptors | ||
| oneapi::mkl::dft::descriptor<oneapi::mkl::dft::precision::DOUBLE, | ||
| 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<double>> input_buffer(input_data.data(), sycl::range<1>(N)); | ||
| sycl::buffer<std::complex<double>> output_buffer(output_data.data(), sycl::range<1>(N)); | ||
| oneapi::mkl::dft::compute_forward<decltype(desc), std::complex<double>, | ||
| std::complex<double>>(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 double precision (double) data type\n" | ||
| "#\n" | ||
| "# For Intel CPU with Intel MKLCPU 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 double 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.