Skip to content

Commit e8e3dab

Browse files
authored
[LAPACK] Enable LAPACK domain
Enables the LAPACK domain according to the oneMKL specification. Support for mklcpu and mklgpu backends.
1 parent ba29506 commit e8e3dab

File tree

89 files changed

+32473
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+32473
-18
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ if(ENABLE_MKLCPU_BACKEND
7777
OR ENABLE_NETLIB_BACKEND)
7878
list(APPEND DOMAINS_LIST "blas")
7979
endif()
80+
if(ENABLE_MKLCPU_BACKEND
81+
OR ENABLE_MKLGPU_BACKEND)
82+
list(APPEND DOMAINS_LIST "lapack")
83+
endif()
8084
if(ENABLE_MKLCPU_BACKEND
8185
OR ENABLE_MKLGPU_BACKEND
8286
OR ENABLE_CURAND_BACKEND)

README.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ $> clang++ -fsycl app.o –L$ONEMKL/lib –lonemkl_blas_mklcpu –lonemkl_blas_c
107107

108108
### Supported Configurations:
109109

110-
Supported domains: BLAS, RNG
110+
Supported domains: BLAS, LAPACK, RNG
111111

112112
#### Linux*
113113

@@ -141,6 +141,16 @@ Supported domains: BLAS, RNG
141141
<td align="center">NETLIB LAPACK</td>
142142
<td align="center">Dynamic, Static</td>
143143
</tr>
144+
<tr>
145+
<td rowspan=2 align="center">LAPACK</td>
146+
<td align="center">x86 CPU</td>
147+
<td rowspan=2 align="center">Intel(R) oneAPI Math Kernel Library</td>
148+
<td align="center">Dynamic, Static</td>
149+
</tr>
150+
<tr>
151+
<td align="center">Intel GPU</td>
152+
<td align="center">Dynamic, Static</td>
153+
</tr>
144154
<tr>
145155
<td rowspan=3 align="center">RNG</td>
146156
<td align="center">x86 CPU</td>
@@ -186,6 +196,16 @@ Supported domains: BLAS, RNG
186196
<td align="center">NETLIB LAPACK</td>
187197
<td align="center">Dynamic, Static</td>
188198
</tr>
199+
<tr>
200+
<td rowspan=2 align="center">LAPACK</td>
201+
<td align="center">x86 CPU</td>
202+
<td rowspan=2 align="center">Intel(R) oneAPI Math Kernel Library</td>
203+
<td align="center">Dynamic, Static</td>
204+
</tr>
205+
<tr>
206+
<td align="center">Intel GPU</td>
207+
<td align="center">Dynamic, Static</td>
208+
</tr>
189209
<tr>
190210
<td align="center">RNG</td>
191211
<td align="center">x86 CPU</td>
@@ -491,8 +511,9 @@ Then:
491511
# Inside <path to onemkl>
492512
mkdir build && cd build
493513
export CXX=<path_to_dpcpp_compiler>/bin/dpcpp;
494-
cmake .. [-DMKL_ROOT=<mkl_install_prefix>] \ # required only if environment variable MKLROOT is not set
495-
[-DREF_BLAS_ROOT=<reference_blas_install_prefix>] # required only for testing
514+
cmake .. [-DMKL_ROOT=<mkl_install_prefix>] \ # required only if environment variable MKLROOT is not set
515+
[-DREF_BLAS_ROOT=<reference_blas_install_prefix>] \ # required only for testing
516+
[-DREF_LAPACK_ROOT=<reference_lapack_install_prefix>] # required only for testing
496517
cmake --build .
497518
ctest
498519
cmake --install . --prefix <path_to_install_dir>
@@ -502,8 +523,9 @@ cmake --install . --prefix <path_to_install_dir>
502523
# Inside <path to onemkl>
503524
md build && cd build
504525
cmake .. -G Ninja
505-
[-DMKL_ROOT=<mkl_install_prefix>] \ # required only if environment variable MKLROOT is not set
506-
[-DREF_BLAS_ROOT=<reference_blas_install_prefix>] # required only for testing
526+
[-DMKL_ROOT=<mkl_install_prefix>] \ # required only if environment variable MKLROOT is not set
527+
[-DREF_BLAS_ROOT=<reference_blas_install_prefix>] \ # required only for testing
528+
[-DREF_LAPACK_ROOT=<reference_lapack_install_prefix>] # required only for testing
507529

508530
ninja
509531
ctest

cmake/FindLAPACKE.cmake

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#===============================================================================
2+
# Copyright 2021 Intel Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing,
11+
# software distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions
14+
# and limitations under the License.
15+
#
16+
#
17+
# SPDX-License-Identifier: Apache-2.0
18+
#===============================================================================
19+
20+
include_guard()
21+
22+
find_library(LAPACKE64_file NAMES lapacke64.dll.lib lapacke64.lib lapacke64 HINTS ${REF_LAPACK_ROOT} PATH_SUFFIXES lib lib64)
23+
find_package_handle_standard_args(LAPACKE64 REQUIRED_VARS LAPACKE64_file)
24+
find_library(LAPACK64_file NAMES lapack64.dll.lib lapack64.lib lapack64 HINTS ${REF_LAPACK_ROOT} PATH_SUFFIXES lib lib64)
25+
find_package_handle_standard_args(LAPACK64 REQUIRED_VARS LAPACK64_file)
26+
find_library(CBLAS64_file NAMES cblas64.dll.lib cblas64.lib cblas64 HINTS ${REF_LAPACK_ROOT} PATH_SUFFIXES lib lib64)
27+
find_package_handle_standard_args(CBLAS64 REQUIRED_VARS CBLAS64_file)
28+
find_library(BLAS64_file NAMES blas64.dll.lib blas64.lib blas64 HINTS ${REF_LAPACK_ROOT} PATH_SUFFIXES lib lib64)
29+
find_package_handle_standard_args(BLAS64 REQUIRED_VARS BLAS64_file)
30+
31+
get_filename_component(LAPACKE64_LIB_DIR ${LAPACKE64_file} DIRECTORY)
32+
find_path(LAPACKE_INCLUDE lapacke.h HINTS ${REF_LAPACK_ROOT} PATH_SUFFIXES include)
33+
34+
if(UNIX)
35+
list(APPEND LAPACKE_LINK "-Wl,-rpath,${LAPACKE64_LIB_DIR}")
36+
endif()
37+
list(APPEND LAPACKE_LINK ${LAPACKE64_file})
38+
list(APPEND LAPACKE_LINK ${LAPACK64_file})
39+
list(APPEND LAPACKE_LINK ${CBLAS64_file})
40+
list(APPEND LAPACKE_LINK ${BLAS64_file})
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(LAPACKE64 REQUIRED_VARS LAPACKE_INCLUDE LAPACKE_LINK)

cmake/FindMKL.cmake

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ endif()
3535

3636
list(APPEND MKL_C ${MKL_CORE})
3737

38+
if(ENABLE_MKLGPU_BACKEND)
39+
set(USE_DPCPP_API ON)
40+
endif()
41+
3842
if (ENABLE_MKLCPU_BACKEND OR ENABLE_MKLGPU_BACKEND)
39-
if(ENABLE_MKLGPU_BACKEND)
43+
if(USE_DPCPP_API)
4044
list(APPEND MKL_LIBRARIES ${MKL_SYCL})
4145
endif()
4246
list(APPEND MKL_LIBRARIES ${MKL_C})
@@ -56,7 +60,7 @@ find_path(MKL_INCLUDE mkl.h
5660
HINTS $ENV{MKLROOT} ${MKL_ROOT}
5761
PATH_SUFFIXES include)
5862

59-
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8 OR ENABLE_MKLGPU_BACKEND)
63+
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8 OR USE_DPCPP_API)
6064
set(MKL_COPT "-DMKL_ILP64")
6165
else()
6266
set(MKL_COPT "")
@@ -82,13 +86,13 @@ if (ENABLE_MKLCPU_BACKEND OR ENABLE_MKLGPU_BACKEND)
8286
if(ENABLE_MKLCPU_THREAD_TBB)
8387
list(APPEND MKL_LINK_C ${TBB_LINK})
8488
endif()
85-
if(ENABLE_MKLGPU_BACKEND)
89+
if(USE_DPCPP_API)
8690
set(MKL_LINK_SYCL ${MKL_LINK_PREFIX} ${LIB_PREFIX}${MKL_SYCL}${LIB_SUFFIX} ${MKL_LINK_C} ${OPENCL_LIBNAME} )
8791
endif()
8892
endif()
8993

90-
if (ENABLE_MKLCPU_BACKEND)
91-
find_package_handle_standard_args(MKL REQUIRED_VARS MKL_INCLUDE MKL_COPT MKL_LINK_C)
92-
else(ENABLE_MKLGPU_BACKEND)
94+
if (USE_DPCPP_API)
9395
find_package_handle_standard_args(MKL REQUIRED_VARS MKL_INCLUDE MKL_COPT MKL_LINK_SYCL)
94-
endif()
96+
else(ENABLE_MKLCPU_BACKEND)
97+
find_package_handle_standard_args(MKL REQUIRED_VARS MKL_INCLUDE MKL_COPT MKL_LINK_C)
98+
endif()

include/oneapi/mkl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "oneapi/mkl/types.hpp"
2424

2525
#include "oneapi/mkl/blas.hpp"
26+
#include "oneapi/mkl/lapack.hpp"
2627
#include "oneapi/mkl/rng.hpp"
2728

2829
#endif //_ONEMKL_HPP_

include/oneapi/mkl/detail/backends_table.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace oneapi {
3737
namespace mkl {
3838

3939
enum class device : uint16_t { x86cpu, intelgpu, nvidiagpu };
40-
enum class domain : uint16_t { blas, rng };
40+
enum class domain : uint16_t { blas, lapack, rng };
4141

4242
static std::map<domain, std::map<device, std::vector<const char*>>> libraries = {
4343
{ domain::blas,
@@ -63,6 +63,20 @@ static std::map<domain, std::map<device, std::vector<const char*>>> libraries =
6363
#endif
6464
} } } },
6565

66+
{ domain::lapack,
67+
{ { device::x86cpu,
68+
{
69+
#ifdef ENABLE_MKLCPU_BACKEND
70+
LIB_NAME("lapack_mklcpu")
71+
#endif
72+
} },
73+
{ device::intelgpu,
74+
{
75+
#ifdef ENABLE_MKLGPU_BACKEND
76+
LIB_NAME("lapack_mklgpu")
77+
#endif
78+
} } } },
79+
6680
{ domain::rng,
6781
{ { device::x86cpu,
6882
{
@@ -85,6 +99,7 @@ static std::map<domain, std::map<device, std::vector<const char*>>> libraries =
8599
};
86100

87101
static std::map<domain, const char*> table_names = { { domain::blas, "mkl_blas_table" },
102+
{ domain::lapack, "mkl_lapack_table" },
88103
{ domain::rng, "mkl_rng_table" } };
89104

90105
} //namespace mkl

include/oneapi/mkl/lapack.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*******************************************************************************
2+
* Copyright 2021 Intel Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions
14+
* and limitations under the License.
15+
*
16+
*
17+
* SPDX-License-Identifier: Apache-2.0
18+
*******************************************************************************/
19+
20+
#pragma once
21+
22+
#include "oneapi/mkl/detail/config.hpp"
23+
24+
#ifdef ENABLE_MKLCPU_BACKEND
25+
#include "oneapi/mkl/lapack/detail/mklcpu/lapack_ct.hpp"
26+
#endif
27+
#ifdef ENABLE_MKLGPU_BACKEND
28+
#include "oneapi/mkl/lapack/detail/mklgpu/lapack_ct.hpp"
29+
#endif
30+
31+
#include "oneapi/mkl/lapack/detail/lapack_rt.hpp"

0 commit comments

Comments
 (0)