{-# LANGUAGE CPP, FlexibleContexts #-}#include "fusion-phases.h"-- | Definition of the PArray type, and functions that work on it. The PArray-- type is a PData with an array length. The functions we export from this-- module are just wrappers for the PD functions from Data.Array.Parallel.PArray.PRepr.---- TODO: Check inconsistent use of INLINE pragmas.-- Most have INLINE_PA, but bpermutePD and nfPD have plain INLINE--moduleData.Array.Parallel.PArray.Base(PArray(..),lengthPA#,dataPA#,-- These functions have corresponding members in the PR class-- from Data.Array.Parallel.PArray.PData.emptyPA,replicatePA#,replicatelPA#,repeatPA#,indexPA#,extractPA#,bpermutePA#,appPA#,applPA#,packByTagPA#,combine2PA#,updatePA#,fromListPA#,fromListPA,nfPA,)whereimportData.Array.Parallel.Lifted.Unboxed(elementsSegd#)importData.Array.Parallel.PArray.PDataimportData.Array.Parallel.PArray.PReprimportData.Array.Parallel.Base(Tag)importqualifiedData.Array.Parallel.UnliftedasUimportGHC.Exts(Int#,Int(..),(+#),(*#))importSpecConstr-- | Lifted\/bulk parallel arrays-- This contains the array length, along with the element data.--{-# ANN type PArray NoSpecConstr #-}dataPArraya=PArrayInt#(PDataa)-- | Take the length field of a PArray.lengthPA#::PArraya->Int#{-# INLINE_PA lengthPA# #-}lengthPA#(PArrayn#_)=n#-- | Take the data field of a PArray.dataPA#::PArraya->PDataa{-# INLINE_PA dataPA# #-}dataPA#(PArray_d)=d-- PA Wrappers ------------------------------------------------------------------ These wrappers work on PArrays. As the PArray contains a PData, we can -- can just pass this to the corresponding PD function from -- Data.Array.Parallel.PArray.PRepr. However, as a PData doesn't contain -- the array length, we need to do the length calculations here.---- Note: There are some more operator# functions that work on PArrays in -- "Data.Array.Parallel.PArray.DataInstances". The ones there have -- a similar shape but need to know about the underlying representation-- constructors.-- emptyPA::PAa=>PArraya{-# INLINE_PA emptyPA #-}emptyPA=PArray0#emptyPDreplicatePA#::PAa=>Int#->a->PArraya{-# INLINE_PA replicatePA# #-}replicatePA#n#x=PArrayn#(replicatePDn#x)replicatelPA#::PAa=>U.Segd->PArraya->PArraya{-# INLINE_PA replicatelPA# #-}replicatelPA#segd(PArray_xs)=PArray(elementsSegd#segd)(replicatelPDsegdxs)repeatPA#::PAa=>Int#->PArraya->PArraya{-# INLINE_PA repeatPA# #-}repeatPA#m#(PArrayn#xs)=PArray(m#*#n#)(repeatPDm#n#xs)indexPA#::PAa=>PArraya->Int#->a{-# INLINE_PA indexPA# #-}indexPA#(PArray_xs)i#=indexPDxsi#extractPA#::PAa=>PArraya->Int#->Int#->PArraya{-# INLINE_PA extractPA# #-}extractPA#(PArray_xs)i#n#=PArrayn#(extractPDxsi#n#)bpermutePA#::PAa=>PArraya->Int#->U.ArrayInt->PArraya{-# INLINE bpermutePA# #-}bpermutePA#(PArray_xs)n#is=PArrayn#(bpermutePDxsn#is)appPA#::PAa=>PArraya->PArraya->PArraya{-# INLINE_PA appPA# #-}appPA#(PArraym#xs)(PArrayn#ys)=PArray(m#+#n#)(appPDxsys)applPA#::PAa=>U.Segd->U.Segd->PArraya->U.Segd->PArraya->PArraya{-# INLINE_PA applPA# #-}applPA#segdis(PArraym#xs)js(PArrayn#ys)=PArray(m#+#n#)(applPDsegdisxsjsys)packByTagPA#::PAa=>PArraya->Int#->U.ArrayTag->Int#->PArraya{-# INLINE_PA packByTagPA# #-}packByTagPA#(PArray_xs)n#tagst#=PArrayn#(packByTagPDxsn#tagst#)combine2PA#::PAa=>Int#->U.Sel2->PArraya->PArraya->PArraya{-# INLINE_PA combine2PA# #-}combine2PA#n#sel(PArray_as)(PArray_bs)=PArrayn#(combine2PDn#selasbs)updatePA#::PAa=>PArraya->U.ArrayInt->PArraya->PArraya{-# INLINE_PA updatePA# #-}updatePA#(PArrayn#xs)is(PArray_ys)=PArrayn#(updatePDxsisys)fromListPA#::PAa=>Int#->[a]->PArraya{-# INLINE_PA fromListPA# #-}fromListPA#n#xs=PArrayn#(fromListPDn#xs)fromListPA::PAa=>[a]->PArraya{-# INLINE fromListPA #-}fromListPAxs=caselengthxsofI#n#->fromListPA#n#xsnfPA::PAa=>PArraya->(){-# INLINE nfPA #-}nfPA(PArray_xs)=nfPDxs