Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write Haskell array strategies

Tags:

arrays

haskell

I want to write a strategy to evaluate items in an array in parallel. The old strategies had parArr to do this (see here). But this is not found in the new Control.Parallel.Strategies module.

E.g. parallel list evaluation: map f myList `using` parList rdeepseq

I would want to be able to do something like: amap f myArr `using` parArr rdeepseq, where amap is from Data.Array.Base and applies a function to each of the elements (sequentially).

The following seems to work but I wonder if it is doing it right, and want to know how I could define my own parArr.

This works: amap ((+1) `using` rpar) $ Array.array (0,4) [(0,10),(1,20),(2,30),(3,40),(4,50)]

like image 879
vis Avatar asked Jul 04 '11 20:07

vis


1 Answers

For a previous question, I wrote a parallel evaluation strategy for the vector package. That should be a good place to start. You can see the code on hackage in the vector-strategies package.

I don't have time to give a full answer - perhaps I'll edit this later. Feel free to comment with extra questions and direction.

like image 95
Thomas M. DuBuisson Avatar answered Oct 04 '22 19:10

Thomas M. DuBuisson