Skip to content

Commit ece8283

Browse files
committed
Add oneMKL BLAS Level 1 copy support
Fix and add test for 'copy' Fix onemklZcopy/onemklCcopy mapping errors and remove redundant test setup code in onemkl.jl test Remove oneAPI.L0 check. Remove using Test
1 parent 8140fe4 commit ece8283

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

deps/onemkl.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ extern "C" int onemklZgemm(syclQueue_t device_queue, onemklTranspose transA,
8181
return 0;
8282
}
8383

84+
extern "C" void onemklDcopy(syclQueue_t device_queue, int64_t n, const double *x,
85+
int64_t incx, double *y, int64_t incy) {
86+
oneapi::mkl::blas::column_major::copy(device_queue->val, n, x, incx, y, incy);
87+
}
88+
89+
extern "C" void onemklScopy(syclQueue_t device_queue, int64_t n, const float *x,
90+
int64_t incx, float *y, int64_t incy) {
91+
oneapi::mkl::blas::column_major::copy(device_queue->val, n, x, incx, y, incy);
92+
}
93+
94+
extern "C" void onemklZcopy(syclQueue_t device_queue, int64_t n, const double _Complex *x,
95+
int64_t incx, double _Complex *y, int64_t incy) {
96+
oneapi::mkl::blas::column_major::copy(device_queue->val, n,
97+
reinterpret_cast<const std::complex<double> *>(x), incx,
98+
reinterpret_cast<std::complex<double> *>(y), incy);
99+
}
100+
101+
extern "C" void onemklCcopy(syclQueue_t device_queue, int64_t n, const float _Complex *x,
102+
int64_t incx, float _Complex *y, int64_t incy) {
103+
oneapi::mkl::blas::column_major::copy(device_queue->val, n,
104+
reinterpret_cast<const std::complex<float> *>(x), incx,
105+
reinterpret_cast<std::complex<float> *>(y), incy);
106+
}
84107

85108
// other
86109

deps/onemkl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ int onemklZgemm(syclQueue_t device_queue, onemklTranspose transA,
3939
const double _Complex *B, int64_t ldb, double _Complex beta,
4040
double _Complex *C, int64_t ldc);
4141

42+
void onemklDcopy(syclQueue_t device_queue, int64_t n, const double *x,
43+
int64_t incx, double *y, int64_t incy);
44+
void onemklScopy(syclQueue_t device_queue, int64_t n, const float *x,
45+
int64_t incx, float *y, int64_t incy);
46+
void onemklZcopy(syclQueue_t device_queue, int64_t n, const double _Complex *x,
47+
int64_t incx, double _Complex *y, int64_t incy);
48+
void onemklCcopy(syclQueue_t device_queue, int64_t n, const float _Complex *x,
49+
int64_t incx, float _Complex *y, int64_t incy);
50+
4251
void onemklDestroy();
4352
#ifdef __cplusplus
4453
}

lib/mkl/libonemkl.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,28 @@ function onemklZgemm(device_queue, transA, transB, m, n, k, alpha, A, lda, B, ld
4141
B::ZePtr{ComplexF64}, ldb::Int64, beta::ComplexF64,
4242
C::ZePtr{ComplexF64}, ldc::Int64)::Cint
4343
end
44+
45+
function onemklDcopy(device_queue, n, x, incx, y, incy)
46+
@ccall liboneapi_support.onemklDcopy(device_queue::syclQueue_t, n::Int64,
47+
x::ZePtr{Cdouble}, incx::Int64,
48+
y::ZePtr{Cdouble}, incy::Int64)::Cvoid
49+
end
50+
51+
function onemklScopy(device_queue, n, x, incx, y, incy)
52+
@ccall liboneapi_support.onemklScopy(device_queue::syclQueue_t, n::Int64,
53+
x::ZePtr{Cfloat}, incx::Int64,
54+
y::ZePtr{Cfloat}, incy::Int64)::Cvoid
55+
end
56+
57+
function onemklZcopy(device_queue, n, x, incx, y, incy)
58+
@ccall liboneapi_support.onemklZcopy(device_queue::syclQueue_t, n::Int64,
59+
x::ZePtr{ComplexF64}, incx::Int64,
60+
y::ZePtr{ComplexF64}, incy::Int64)::Cvoid
61+
end
62+
63+
function onemklCcopy(device_queue, n, x, incx, y, incy)
64+
@ccall liboneapi_support.onemklCcopy(device_queue::syclQueue_t, n::Int64,
65+
x::ZePtr{ComplexF32}, incx::Int64,
66+
y::ZePtr{ComplexF32}, incy::Int64)::Cvoid
67+
end
68+

lib/mkl/wrappers.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ end
2020
# BLAS
2121
#
2222

23+
# level 1
24+
## copy
25+
for (fname, elty) in
26+
((:onemklDcopy,:Float64),
27+
(:onemklScopy,:Float32),
28+
(:onemklZcopy,:ComplexF64),
29+
(:onemklCcopy,:ComplexF32))
30+
@eval begin
31+
function copy!(n::Integer,
32+
x::StridedArray{$elty},
33+
y::StridedArray{$elty})
34+
queue = global_queue(context(x), device(x))
35+
$fname(sycl_queue(queue), n, x, stride(x, 1), y, stride(y, 1))
36+
y
37+
end
38+
end
39+
end
40+
41+
2342
# level 3
2443

2544
for (fname, elty) in

test/onemkl.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using oneAPI
2+
using oneAPI.oneMKL
3+
4+
using LinearAlgebra
5+
6+
m = 20
7+
n = 35
8+
k = 13
9+
10+
############################################################################################
11+
@testset "level 1" begin
12+
@testset for T in intersect(eltypes, [Float32, Float64, ComplexF32, ComplexF64])
13+
A = oneArray(rand(T, m))
14+
B = oneArray{T}(undef, m)
15+
oneMKL.copy!(m,A,B)
16+
@test Array(A) == Array(B)
17+
end # level 1 testset
18+
end

0 commit comments

Comments
 (0)