AccelerateHS / AccelerateHS/accelerate

Locally mutable batched access to arrays

Offen
#216 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
language new feature
Vorherrschende Sprache
Haskell
Sterne
1k
Forks
135
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

The batched LU decomposition of CUBLAS, namely `getrfBatched`, returns a pivot array, but the batched LU solver `trsmBatched` does not accept a pivot array as parameter. Thus I have to apply the permutations manually that are implied by the pivot array. Unfortunately, the pivot array cannot be translated into a permutation as required by `permute` or `backpermute`. Thus I have to fetch the pivot array from the GPU, convert the pivot array into a permutation vector on the CPU using the mutable vector type of the `vector` library and apply the resulting permutation vector with `backpermute` on the GPU. Here is the conversion function that works on `Vector.Storable.Mutable`:

```
permutationFromPivotsMutableBackward ::
V.Vector Word32 -> MV.MVector s Word32 -> ST s ()
permutationFromPivotsMutableBackward pivots perm = do
zipWithM_
(\k j -> do
MV.write perm k (fromIntegral k)
MV.swap perm k (fromIntegral j))
(iterate (subtract 1) $ V.length pivots - 1) (V.toList $ V.reverse pivots)
```

A batched loop which allows mutations (in this case: element swaps) of an array would be great to have in `accelerate` or at least in `accelerate-cuda`.

Unfortunately, I have no concrete idea, what API is both useful and implementable on CUDA. There must be a separation between the outer parallelizable loop for the batch operation and the inner sequential loop for mutable manipulations.

See according post to the Accelerate mailing list: https://groups.google.com/forum/#!topic/accelerate-haskell/OSb53e4yF4Q

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.