haskell - GHC can't handle large lookup tables -
i need use lookup table in 3 dimensions. table has 73x73x73 (389017) double values.
module hammer.texture.table3d import qualified data.vector v import qualified data.vector.unboxed u import data.vector.unboxed (vector) table3d :: v.vector (v.vector (vector double)) table3d = v.fromlist [table0, table1, ... table72] table0 = v.fromlist $ map u.fromlist [ [1.973921e+01, 0.000000e+00, ... 0.000000e+00], ..... [1.973921e+01, 0.000000e+00, ... 0.000000e+00]] ..... table72 = v.fromlist $ map u.fromlist [ [1.973921e+01, 0.000000e+00, ... 0.000000e+00], ..... [1.973921e+01, 0.000000e+00, ... 0.000000e+00]]
the problem ghc can't handle size of vector double or [double], ghc compilation takes lot of time (~ 2 min) until, finally, memory blows up. seems there memory leak on ghc or bug because works fine large string ([char]).
what solutions, if any, available creating "large" lookup tables (double type) using ghc?
i can think of 2 possibilities:
- serialize vectors file, , @ program startup deserialize them (perhaps using unsafeinterleaveio if happen when lookup table first used rather when program starts).
- if lookup table sparse pseudocode suggests, consider using sparse data structure -- e.g.
data.map
or plain function. if necessary, can use sparse data structure generate vectors (again @ runtime).
Comments
Post a Comment