Re: [accelerate-haskell] Avoiding nested parallelism

Skip to first unread message

Trevor McDonell

May 21, 2017, 12:41:22 AM5/21/17

Hi Panos,

I am trying to process an Acc (Vector e) in the following way:
a) Apply take n and drop n repeatedly to get an [Acc (Vector e)].
b) Process each element (e.g.
c) Join the results back together with Data.Array.Accelerate.++.

I keep running into the error "Cyclic definition of a value of type 'Acc'", which I believe is an indication of nested parallelism? My question is, is the above design itself (regardless of the particular operations) responsible for this?

Yes, this error is most commonly encountered through use of nested parallelism.

The above structure might be okay, but I wonder…

  • Where does n come from?

  • How are you controlling the list generation in Haskell-land? Be careful; you won’t be able to use any results from Accelerate-land to control this (this is perhaps one of the trickiest parts of embedded languages—-being very clear on which phase each part of your program occurs in, and not mixing the two in the wrong way (well, I guess you can do this, buy splitting your program into multiple Haskell -> run -> Haskell -> run … cycles)).

  • Probably you are processing each element of the list of Accelerate expressions in some more complex way than (since the rank-polymorphic operations should be able to handle this already?), but maybe there should be a way to do this in Accelerate land instead. Maybe you need a segmented operation?

And if it is: I worked around some of the above errors by using replicate and fold, but what design should one use if the operations cannot be expressed in terms of fold (e.g. some arbitrary function of all/many elements in a row)?

Could you give me a more concrete example of the kind of thing you want to do? This might help me answer the above as well, since I think I am just a bit confused…

The operators in Accelerate are all collective operations; i.e., apply some function to every element of an array in data-parallel. I vaguely feel like maybe your problem is more related to control flow (i.e. how to piece the different parts of your application together)?

P.S. How does one apply inline code markup with Google Groups? I keep getting block markup.

I’m using this plugin:


You received this message because you are subscribed to the Google Groups "Accelerate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
Visit this group at
For more options, visit

Reply all
Reply to author
0 new messages