Changes between Version 31 and Version 32 of SIMDPlan


Ignore:
Timestamp:
Oct 27, 2011 5:12:08 PM (4 years ago)
Author:
pmonday
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SIMDPlan

    v31 v32  
    370370'''Question:'''  How does one create one of the new PrimOp types to test prior to testing the vector add operations?  This is going to have to be looked at a little ... the code should basically create a vector and then insertDoubleVec# repeatedly to populate the vector.  Without the subsequent steps done, this will have to be "hand" done without additional operations defined.  Here is the response from Manuel to expand on this:  I am not quite sure what the best approach is. The intention in LLVM is clearly to populate vectors using the 'insertIntVec#' etc functions. However, in LLVM you can just use an uninitialised register and insert elements into a vector successively. We could provide a vector "0" value in Haskell and insert into that. Any other ideas?
    371371{{{
    372         let x = ????
    373         let y = ???
    374         plusDoubleVec# x y
    375 }}}     
    376 Using simple lists to achieve the same operation:
    377 {{{
    378         let x = [1,2,3,4]
    379         let y = [2,3,4,5]
    380         zipWith (+) x y
     372{-# LANGUAGE MagicHash #-}
     373import GHC.Prim
     374import GHC.Exts
     375
     376getPrimFloat :: Float -> Float#
     377getPrimFloat f = case f of { F# f -> f }
     378
     379main = do
     380    numberString <- getLine
     381    let num = read numberString
     382    let value = getPrimFloat num
     383    numberString2 <- getLine
     384    let num2 = read numberString2
     385    let value2 = getPrimFloat num2
     386   
     387    let packedVector1 = pack4FloatOp# value value value value
     388    let packedVector2 = pack4FloatOp# value2 value2 value2 value2
     389
     390    let resultVector = multFloatVec4# packedVector1 packedVector2
     391   
     392    let result = extractFloatVec# resultVector 1
     393
     394    let resultFloat = F# result
     395    print resultFloat
     396}}}
     397       
     398Using simple lists to achieve the same operation (note that the below is Integer only, I have to modify it to read floats off the command line otherwise a parse error occurs after the reads).
     399
     400{{{
     401main = do
     402    numberString <- getLine
     403    let value = read numberString
     404    numberString2 <- getLine
     405    let value2 = read numberString2
     406
     407    let list1 = [value,value,value,value]
     408    let list2 = [value2,value2,value2,value2]
     409
     410    let result = zipWith (*) list1 list2
     411
     412    print (result !! 1)
    381413}}}
    382414