-
Notifications
You must be signed in to change notification settings - Fork 177
Openblas backend implementation #722
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
Open
CDAC-SSDG
wants to merge
2
commits into
uxlfoundation:develop
Choose a base branch
from
CDAC-Bengaluru:openblas-backend-implementation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #=============================================================================== | ||
| # Copyright 2020-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 | ||
| #=============================================================================== | ||
|
|
||
| include_guard() | ||
| include(FindPackageHandleStandardArgs) | ||
|
|
||
| if(DEFINED OPENBLAS_DIR) | ||
| set(_OPENBLAS_HINTS ${OPENBLAS_DIR}) | ||
| elseif(DEFINED ENV{OPENBLAS_DIR}) | ||
| set(_OPENBLAS_HINTS $ENV{OPENBLAS_DIR}) | ||
| elseif(CMAKE_PREFIX_PATH) | ||
| set(_OPENBLAS_HINTS ${CMAKE_PREFIX_PATH}) | ||
| endif() | ||
|
|
||
|
|
||
| find_library(OPENBLAS_LIBRARY | ||
| NAMES openblas libopenblas | ||
| HINTS ${_OPENBLAS_HINTS} | ||
| PATH_SUFFIXES lib lib64 | ||
| ) | ||
|
|
||
| find_path(OPENBLAS_INCLUDE | ||
| NAMES cblas.h | ||
| HINTS ${_OPENBLAS_HINTS} | ||
| PATH_SUFFIXES include include/openblas | ||
| ) | ||
|
|
||
| find_package_handle_standard_args(OpenBLAS | ||
| REQUIRED_VARS OPENBLAS_LIBRARY OPENBLAS_INCLUDE | ||
| ) | ||
|
|
||
| if(OpenBLAS_FOUND) | ||
|
|
||
| get_filename_component(OPENBLAS_LIB_DIR | ||
| ${OPENBLAS_LIBRARY} | ||
| DIRECTORY | ||
| ) | ||
|
|
||
| add_library(ONEMATH::OPENBLAS::OPENBLAS UNKNOWN IMPORTED) | ||
|
|
||
| set_target_properties(ONEMATH::OPENBLAS::OPENBLAS PROPERTIES | ||
| IMPORTED_LOCATION ${OPENBLAS_LIBRARY} | ||
| INTERFACE_INCLUDE_DIRECTORIES ${OPENBLAS_INCLUDE} | ||
| ) | ||
|
|
||
| if(UNIX AND OPENBLAS_LIB_DIR) | ||
| set_target_properties(ONEMATH::OPENBLAS::OPENBLAS PROPERTIES | ||
| INTERFACE_LINK_OPTIONS "-Wl,-rpath,${OPENBLAS_LIB_DIR}" | ||
| ) | ||
| endif() | ||
|
|
||
| endif() | ||
|
|
||
| mark_as_advanced( | ||
| OPENBLAS_LIBRARY | ||
| OPENBLAS_INCLUDE | ||
| ) | ||
|
|
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
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,175 @@ | ||
| .. _building_the_project_with_openblas: | ||
|
|
||
| Building the Project with OpenBLAS | ||
| ================================== | ||
|
|
||
| This page describes building oneMath with the OpenBLAS backend using | ||
| different SYCL implementations: | ||
|
|
||
| - DPC++ (Intel oneAPI) | ||
| - AdaptiveCpp | ||
|
|
||
| Environment Setup | ||
| ################# | ||
|
|
||
| #. | ||
| Install and build OpenBLAS. The installation prefix will be referred to as | ||
| ``<path to openblas>``. | ||
|
|
||
| #. | ||
| Clone this project. The root directory will be referred to as | ||
| ``<path to onemath>``. | ||
|
|
||
| #. | ||
| (Optional) Install a reference BLAS/LAPACK implementation for functional | ||
| testing. The installation prefix will be referred to as | ||
| ``<path to reference lapack install>``. | ||
|
|
||
| #. | ||
| Ensure required shared libraries are visible at runtime: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| export LD_LIBRARY_PATH=<path to system libraries>:$LD_LIBRARY_PATH | ||
| export LD_LIBRARY_PATH=<path to openblas>/lib:$LD_LIBRARY_PATH | ||
|
|
||
| # Optional (only if functional tests are enabled) | ||
| export LD_LIBRARY_PATH=<path to reference lapack install>/lib:$LD_LIBRARY_PATH | ||
|
|
||
|
|
||
| Building with DPC++ | ||
| ################### | ||
|
|
||
| If using Intel oneAPI DPC++, load the compiler environment: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| source <path to dpcpp environment script> | ||
|
|
||
| Build commands: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| cd <path to onemath> | ||
| mkdir build && cd build | ||
|
|
||
| cmake .. \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_C_COMPILER=<path to icx> \ | ||
| -DCMAKE_CXX_COMPILER=<path to icpx> \ | ||
| -DONEMATH_SYCL_IMPLEMENTATION=dpc++ \ | ||
| -DENABLE_MKLCPU_BACKEND=False \ | ||
| -DENABLE_MKLGPU_BACKEND=False \ | ||
| -DENABLE_NETLIB_BACKEND=False \ | ||
| -DENABLE_OPENBLAS_BACKEND=True \ | ||
| -DOPENBLAS_DIR=<path to openblas> \ | ||
| -DBUILD_FUNCTIONAL_TESTS=True \ | ||
| -DBUILD_EXAMPLES=True \ | ||
| -DCMAKE_INSTALL_PREFIX=<path to install directory> \ | ||
| -DREF_BLAS_ROOT=<path to reference lapack install> \ | ||
| -DREF_LAPACK_ROOT=<path to reference lapack install> | ||
|
|
||
| make -j && make install | ||
|
|
||
|
|
||
| Building with AdaptiveCpp | ||
| ######################### | ||
|
|
||
| If using AdaptiveCpp, load the compiler environment: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| source <path to adaptivecpp environment script> | ||
|
|
||
| Build commands: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| cd <path to onemath> | ||
| mkdir build && cd build | ||
|
|
||
| cmake .. \ | ||
| -DCMAKE_BUILD_TYPE=Release \ | ||
| -DCMAKE_C_COMPILER=<path to clang> \ | ||
| -DCMAKE_CXX_COMPILER=<path to acpp> \ | ||
| -DONEMATH_SYCL_IMPLEMENTATION=adaptivecpp \ | ||
| -DACPP_TARGETS=omp \ | ||
| -DENABLE_MKLCPU_BACKEND=False \ | ||
| -DENABLE_MKLGPU_BACKEND=False \ | ||
| -DENABLE_NETLIB_BACKEND=False \ | ||
| -DENABLE_OPENBLAS_BACKEND=True \ | ||
| -DOPENBLAS_DIR=<path to openblas> \ | ||
| -DBUILD_FUNCTIONAL_TESTS=True|False \ | ||
| -DBUILD_EXAMPLES=True \ | ||
| -DCMAKE_INSTALL_PREFIX=<path to install directory> | ||
|
|
||
| make -j && make install | ||
|
|
||
|
|
||
| Common Build Options | ||
| #################### | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
|
|
||
| * - CMake Option | ||
| - Supported Values | ||
| - Description | ||
| * - ONEMATH_SYCL_IMPLEMENTATION | ||
| - dpc++, adaptivecpp | ||
| - Selects the SYCL implementation | ||
| * - ENABLE_OPENBLAS_BACKEND | ||
| - True, False | ||
| - Enables the OpenBLAS backend | ||
| * - OPENBLAS_DIR | ||
| - Path | ||
| - Path to the OpenBLAS installation | ||
| * - ENABLE_MKLCPU_BACKEND | ||
| - True, False | ||
| - Enables/disables MKL CPU backend | ||
| * - ENABLE_MKLGPU_BACKEND | ||
| - True, False | ||
| - Enables/disables MKL GPU backend | ||
| * - ENABLE_NETLIB_BACKEND | ||
| - True, False | ||
| - Enables/disables Netlib backend | ||
| * - BUILD_FUNCTIONAL_TESTS | ||
| - True, False | ||
| - Enables functional tests | ||
| * - BUILD_EXAMPLES | ||
| - True, False | ||
| - Builds example programs | ||
| * - CMAKE_INSTALL_PREFIX | ||
| - Path | ||
| - Installation directory | ||
|
|
||
|
|
||
| Running Tests | ||
| ############# | ||
|
|
||
| Running Test Binaries Directly | ||
| ----------------------------- | ||
|
|
||
| The BLAS test executables are located in the ``bin`` directory inside the | ||
| build folder. | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| cd <path to onemath>/build | ||
|
|
||
| # Run BLAS runtime tests | ||
| ./bin/test_main_blas_rt | ||
|
|
||
| # Run BLAS compile-time tests | ||
| ./bin/test_main_blas_ct | ||
|
|
||
|
|
||
| Notes | ||
| ##### | ||
|
|
||
| * OpenBLAS is used as the CPU BLAS backend in this configuration. | ||
| * Ensure that OpenBLAS shared libraries are available via | ||
| ``LD_LIBRARY_PATH`` or system linker configuration. | ||
| * AdaptiveCpp requires proper target configuration via ``ACPP_TARGETS``. | ||
| * Functional tests require a reference BLAS/LAPACK installation. | ||
| * Test binaries are generated only if functional tests are enabled. |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes!
Looks like this branch
CDAC-Bengaluru:openblas-backend-implementationis not synced with the latest develop branch from the main repo, so this PR contains reverted changes for some recent changes in the develop, like this change is reverting #719.Could you please rebase your branch on the lates develop so these reverted changes will go away?