Writing large n-dim un-boxed array of Int32 quickly?
Hello, I want to write a multi-dimensional unboxed arrary of Int32 to a file. (And also read it back later). What I tried so far is import NewBinary.Binary ... mapM_ (put bin) $ elems array ... but this was exceedlying slow. The array contains about 10 000 000 entries. Any suggestions? Rene.
From: Ketil Malde <ketil@ii.uib.no> Rene de Visser wrote:
I want to write a multi-dimensional unboxed arrary of Int32 to a file. (And also read it back later).
hGetArray/hPutArray?
To do this I need to cast my 5 dimensional array to a 1 dimensional array? Does this work? i.e. how do I know that GHC uses a flat array representation for multidemsional arrays (rather than a nested model using pointers). Rene.
Rene de Visser <rene_de_visser@hotmail.com> wrote in article <BAY103-F1655F7499A305D6517DC50DA6C0@phx.gbl> in gmane.comp.lang.haskell.general:
To do this I need to cast my 5 dimensional array to a 1 dimensional array? Does this work? i.e. how do I know that GHC uses a flat array representation for multidemsional arrays (rather than a nested model using pointers).
You know that the array type you are using uses a flat representation because -it- doesn't know what index type you are using. IOUArray must be polymorphic over the index type (the first argument to the type constructor IOUArray), so it can't do anything with the indices that the Ix type class doesn't tell it how to do. The Ix type class doesn't tell IOUArray how many dimensions you have. But you may also want to look into StorableArray. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig 2005-11-06 Against Exploiting the Environment in War http://tinyurl.com/adhg9 2005-11-20 Universal Children's Day http://www.un.org/depts/dhl/children_day/ 2005-11-25 Elimination of Violence Against Women http://tinyurl.com/drd57 2005-11-25 Buy Nothing Day http://www.buynothingday.co.uk/
Hello Rene, Monday, October 31, 2005, 11:13:30 AM, you wrote: RdV> Hello, RdV> I want to write a multi-dimensional unboxed arrary of Int32 to a file. (And RdV> also read it back later). how about fileWriteBuf/fileReadBuf? -- Best regards, Bulat mailto:bulatz@HotPOP.com
From: Bulat Ziganshin <bulatz@HotPOP.com> Hello Rene,
Monday, October 31, 2005, 11:13:30 AM, you wrote:
RdV> I want to write a multi-dimensional unboxed arrary of Int32 to a file. (And RdV> also read it back later).
how about fileWriteBuf/fileReadBuf? Hello Bulat,
How does this work? (is this from NewBinary, I don't have the sources with me). How do I convert my array to a buffer? Rene.
participants (4)
-
Bulat Ziganshin -
Chung-chieh Shan -
Ketil Malde -
Rene de Visser