@@ -1121,74 +1121,6 @@ end
11211121# end
11221122# end
11231123
1124- # for (jname, bname, fname, elty, relty) in
1125- # ((:syevjBatched!, :rocsolverDnSsyevjBatched_bufferSize, :rocsolverDnSsyevjBatched,
1126- # :Float32, :Float32),
1127- # (:syevjBatched!, :rocsolverDnDsyevjBatched_bufferSize, :rocsolverDnDsyevjBatched,
1128- # :Float64, :Float64),
1129- # (:heevjBatched!, :rocsolverDnCheevjBatched_bufferSize, :rocsolverDnCheevjBatched,
1130- # :ComplexF32, :Float32),
1131- # (:heevjBatched!, :rocsolverDnZheevjBatched_bufferSize, :rocsolverDnZheevjBatched,
1132- # :ComplexF64, :Float64))
1133- # @eval begin
1134- # function $jname(jobz::Char,
1135- # uplo::Char,
1136- # A::StridedROCArray{$elty};
1137- # tol::$relty=eps($relty),
1138- # max_sweeps::Int=100;
1139- # check::Bool = CHECK_LIBRARY_CALLS[],
1140- # )
1141-
1142- # # Set up information for the solver arguments
1143- # chkuplo(uplo)
1144- # n = checksquare(A)
1145- # lda = max(1, stride(A, 2))
1146- # batchSize = size(A, 3)
1147- # W = CuArray{$relty}(undef, n, batchSize)
1148- # params = Ref{syevjInfo_t}(C_NULL)
1149-
1150- # dh = rocBLAS.handle()
1151- # resize!(dh.info, batchSize)
1152-
1153- # # Initialize the solver parameters
1154- # rocsolverDnCreateSyevjInfo(params)
1155- # rocsolverDnXsyevjSetTolerance(params[], tol)
1156- # rocsolverDnXsyevjSetMaxSweeps(params[], max_sweeps)
1157-
1158- # # Calculate the workspace size
1159- # function bufferSize()
1160- # out = Ref{Cint}(0)
1161- # $bname(dh, jobz, uplo, n, A, lda, W, out, params[], batchSize)
1162- # return out[] * sizeof($elty)
1163- # end
1164-
1165- # # Run the solver
1166- # with_workspace(dh.workspace_gpu, bufferSize) do buffer
1167- # return $fname(dh, jobz, uplo, n, A, lda, W, buffer,
1168- # sizeof(buffer) ÷ sizeof($elty), dh.info, params[], batchSize)
1169- # end
1170-
1171- # if check
1172- # # Copy the solver info and delete the device memory
1173- # info = collect(dh.info)
1174- #
1175- # # Double check the solver's exit status
1176- # for i in 1:batchSize
1177- # chkargsok(BlasInt(info[i]))
1178- # end
1179- # end
1180- # rocsolverDnDestroySyevjInfo(params[])
1181-
1182- # # Return eigenvalues (in W) and possibly eigenvectors (in A)
1183- # if jobz == 'N'
1184- # return W
1185- # elseif jobz == 'V'
1186- # return W, A
1187- # end
1188- # end
1189- # end
1190- # end
1191-
11921124# for (fname, elty) in ((:rocsolverDnSpotrsBatched, :Float32),
11931125# (:rocsolverDnDpotrsBatched, :Float64),
11941126# (:rocsolverDnCpotrsBatched, :ComplexF32),
@@ -1500,4 +1432,176 @@ for (heevd, heev, heevx, heevj, elty, relty) in
15001432 end
15011433end
15021434
1435+ for (heevd_batched, heev_batched, heevx_batched, heevj_batched, elty, relty) in
1436+ (
1437+ (:(rocSOLVER. rocsolver_ssyevd_batched), :(rocSOLVER. rocsolver_ssyev_batched), :(rocSOLVER. rocsolver_ssyevx_batched), :(rocSOLVER. rocsolver_ssyevj_batched), :Float32 , :Float32 ),
1438+ (:(rocSOLVER. rocsolver_dsyevd_batched), :(rocSOLVER. rocsolver_dsyev_batched), :(rocSOLVER. rocsolver_dsyevx_batched), :(rocSOLVER. rocsolver_dsyevj_batched), :Float64 , :Float64 ),
1439+ (:(rocSOLVER. rocsolver_cheevd_batched), :(rocSOLVER. rocsolver_cheev_batched), :(rocSOLVER. rocsolver_cheevx_batched), :(rocSOLVER. rocsolver_cheevj_batched), :ComplexF32 , :Float32 ),
1440+ (:(rocSOLVER. rocsolver_zheevd_batched), :(rocSOLVER. rocsolver_zheev_batched), :(rocSOLVER. rocsolver_zheevx_batched), :(rocSOLVER. rocsolver_zheevj_batched), :ComplexF64 , :Float64 ),
1441+ )
1442+ @eval begin
1443+ function heevd_batched! (
1444+ A:: AbstractVector{<:StridedROCMatrix{$elty}} ,
1445+ W:: StridedROCMatrix{$relty} = similar (first (A), $ relty, size (first (A), 1 ), length (A)),
1446+ V:: StridedROCMatrix{$elty} = similar (first (A), $ elty, size (first (A))... , length (A));
1447+ uplo:: Char = ' U' ,
1448+ check:: Bool = CHECK_LIBRARY_CALLS[],
1449+ )
1450+ chkuplo (uplo)
1451+ n = checksquare (first (A))
1452+ batch_size = length (A)
1453+ size (W) == (n, length (A)) || throw (DimensionMismatch (" size mismatch between A and W" ))
1454+ if length (V) == 0
1455+ jobz = rocSOLVER. rocblas_evect_none
1456+ else
1457+ size (V) == (n, n, batch_size) || throw (DimensionMismatch (" size mismatch between A and V" ))
1458+ jobz = rocSOLVER. rocblas_evect_original
1459+ end
1460+ lda = max (1 , stride (first (A), 2 ))
1461+ ldw = max (1 , stride (W, 2 ))
1462+ dh = rocBLAS. handle ()
1463+ work = ROCMatix {$relty} (undef, n, batch_size)
1464+ dev_info = ROCVector {Cint} (undef, batch_size)
1465+ roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
1466+ pA = ROCVector (map (pointer, A))
1467+ $ heevd (dh, jobz, roc_uplo, n, pA, lda, W, ldw, work, n, dev_info, batch_size)
1468+
1469+ if check
1470+ foreach (chkargsok ∘ BlasInt, collect (dev_info))
1471+ end
1472+
1473+ if jobz == rocSOLVER. rocblas_evect_original && V != = A
1474+ copy! (V, A)
1475+ end
1476+ return W, V
1477+ end
1478+ function heev_batched! (
1479+ A:: AbstractVector{<:StridedROCMatrix{$elty}} ,
1480+ W:: StridedROCMatrix{$relty} = similar (first (A), $ relty, size (first (A), 1 ), length (A)),
1481+ V:: StridedROCMatrix{$elty} = similar (first (A), $ elty, size (first (A))... , length (A));
1482+ uplo:: Char = ' U' ,
1483+ check:: Bool = CHECK_LIBRARY_CALLS[],
1484+ )
1485+ chkuplo (uplo)
1486+ n = checksquare (first (A))
1487+ batch_size = length (A)
1488+ size (W) == (n, length (A)) || throw (DimensionMismatch (" size mismatch between A and W" ))
1489+ if length (V) == 0
1490+ jobz = rocSOLVER. rocblas_evect_none
1491+ else
1492+ size (V) == (n, n, batch_size) || throw (DimensionMismatch (" size mismatch between A and V" ))
1493+ jobz = rocSOLVER. rocblas_evect_original
1494+ end
1495+ lda = max (1 , stride (first (A), 2 ))
1496+ ldw = max (1 , stride (W, 2 ))
1497+ dh = rocBLAS. handle ()
1498+ work = ROCMatrix {$relty} (undef, n, batch_size)
1499+ dev_info = ROCVector {Cint} (undef, batch_size)
1500+ roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
1501+ pA = ROCVector (map (pointer, A))
1502+ $ heev (dh, jobz, roc_uplo, n, pA, lda, W, ldw, work, n, dev_info, batch_size)
1503+
1504+ if check
1505+ foreach (chkargsok ∘ BlasInt, collect (dev_info))
1506+ end
1507+
1508+ if jobz == rocSOLVER. rocblas_evect_original && V != = A
1509+ copy! (V, A)
1510+ end
1511+ return W, V
1512+ end
1513+ function heevx_batched! (
1514+ A:: AbstractVector{<:StridedROCMatrix{$elty}} ,
1515+ W:: StridedROCMatrix{$relty} = similar (first (A), $ relty, size (first (A), 1 ), length (A)),
1516+ V:: StridedROCMatrix{$elty} = similar (first (A), $ elty, size (first (A))... , length (A));
1517+ uplo:: Char = ' U' ,
1518+ check:: Bool = CHECK_LIBRARY_CALLS[],
1519+ kwargs...
1520+ )
1521+ chkuplo (uplo)
1522+ n = checksquare (first (A))
1523+ batch_size = length (A)
1524+ size (W) == (n, length (A)) || throw (DimensionMismatch (" size mismatch between A and W" ))
1525+ lda = max (1 , stride (first (A), 2 ))
1526+ ldw = max (1 , stride (W, 2 ))
1527+ if haskey (kwargs, :irange )
1528+ il = first (kwargs[:irange ])
1529+ iu = last (kwargs[:irange ])
1530+ vl = vu = zero ($ relty)
1531+ range = rocSOLVER. rocblas_erange_index
1532+ elseif haskey (kwargs, :vl ) || haskey (kwargs, :vu )
1533+ vl = convert ($ relty, get (kwargs, :vl , - Inf ))
1534+ vu = convert ($ relty, get (kwargs, :vu , + Inf ))
1535+ il = iu = 0
1536+ range = rocSOLVER. rocblas_erange_value
1537+ else
1538+ il = iu = 0
1539+ vl = vu = zero ($ relty)
1540+ range = rocSOLVER. rocblas_erange_all
1541+ end
1542+ if length (V) == 0
1543+ jobz = rocSOLVER. rocblas_evect_none
1544+ else
1545+ size (V) == (n, n, batch_size) || throw (DimensionMismatch (" size mismatch between A and V" ))
1546+ jobz = rocSOLVER. rocblas_evect_original
1547+ end
1548+ dh = rocBLAS. handle ()
1549+ abstol = - one ($ relty)
1550+ nev = ROCVector {Cint} (undef, 1 )
1551+ ldv = max (1 , stride (V, 2 ))
1552+ ifail = ROCMatrix {Cint} (undef, n, batch_size)
1553+ dev_info = ROCVector {Cint} (undef, batch_size)
1554+ roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
1555+ pA = ROCVector (map (pointer, A))
1556+ $ heevx (dh, jobz, range, roc_uplo, n, pA, lda, vl, vu, il, iu, abstol, nev, W, ldw, V, ldv, ifail, n, dev_info, batch_size)
1557+
1558+ if check
1559+ foreach (chkargsok ∘ BlasInt, collect (dev_info))
1560+ end
1561+ m = collect (nev)
1562+ return W, V, m
1563+ end
1564+ function heevj_batched! (
1565+ A:: AbstractVector{<:StridedROCMatrix{$elty}} ,
1566+ W:: StridedROCMatrix{$relty} = similar (first (A), $ relty, size (first (A), 1 ), length (A)),
1567+ V:: StridedROCMatrix{$elty} = similar (first (A), $ elty, size (first (A))... , length (A));
1568+ uplo:: Char = ' U' ,
1569+ tol:: $relty = eps ($ relty),
1570+ max_sweeps:: Int = 100 ,
1571+ sort:: Char = ' N' ,
1572+ check:: Bool = CHECK_LIBRARY_CALLS[],
1573+ )
1574+ chkuplo (uplo)
1575+ n = checksquare (first (A))
1576+ batch_size = length (A)
1577+ size (W) == (n, length (A)) || throw (DimensionMismatch (" size mismatch between A and W" ))
1578+ if length (V) == 0
1579+ jobz = rocSOLVER. rocblas_evect_none
1580+ else
1581+ size (V) == (n, n, batch_size) || throw (DimensionMismatch (" size mismatch between A and V" ))
1582+ jobz = rocSOLVER. rocblas_evect_original
1583+ end
1584+ lda = max (1 , stride (first (A), 2 ))
1585+ ldw = max (1 , stride (W, 2 ))
1586+ dh = rocBLAS. handle ()
1587+ dev_info = ROCVector {Cint} (undef, batch_size)
1588+ residual = ROCVector {$relty} (undef, batch_size)
1589+ n_sweeps = ROCVector {Cint} (undef, batch_size)
1590+ roc_uplo = convert (rocSOLVER. rocblas_fill, uplo)
1591+ roc_sort = sort == ' N' ? rocSOLVER. rocblas_esort_none : rocSOLVER. rocblas_esort_ascending
1592+ pA = ROCVector (map (pointer, A))
1593+ $ heevj (dh, roc_sort, jobz, roc_uplo, n, pA, lda, tol, residual, max_sweeps, n_sweeps, W, ldw, dev_info, batch_size)
1594+
1595+ if check
1596+ foreach (chkargsok ∘ BlasInt, collect (dev_info))
1597+ end
1598+
1599+ if jobz == rocSOLVER. rocblas_evect_original && V != = A
1600+ copy! (V, A)
1601+ end
1602+ return W, V
1603+ end
1604+ end
1605+ end
1606+
15031607end
0 commit comments