<commit_before>
module Examples2 where 

import Obsidian.GCDObsidian

import qualified Obsidian.GCDObsidian.CodeGen.CUDA as CUDA
import qualified Obsidian.GCDObsidian.CodeGen.C as C
import qualified Obsidian.GCDObsidian.CodeGen.OpenCL as CL

import Obsidian.GCDObsidian.Program

import Data.Word
import Data.Bits

import Prelude hiding (zipWith)

----------------------------------------------------------------------------
--

test1 :: GlobalArray Pull (Exp Int) -> Kernel (GlobalArray Push (Exp Int)) 
test1 = pure (block 256) ->- pure (fst . halve) ->- 
        pure (unblock . push) 

getTest1 = putStrLn$ CUDA.genKernelGlob "test1" test1 (GlobalArray undefined (variable "n"):: GlobalArray Pull (Exp Int)) 


testParam1 :: (GlobalArray Pull (Exp Int), Exp Int) -> Kernel (GlobalArray Push (Exp Int)) 
testParam1 (garr, param) = res
  where 
    res = test1$ fmap (+param) garr 

getTestParam1 = putStrLn$ CUDA.genKernelGlob "testParam1" testParam1 (GlobalArray undefined (variable "n") :: GlobalArray Pull (Exp Int),variable "v") 


globRev (GlobalArray (Pull ixf) n) = GlobalArray (Pull (\ix -> ixf (n - 1 - ix))) n

testGlobRev = pure globRev ->- pure (block 256) ->- pure (unblock . push) 

getTestGlobRev = putStrLn$ CUDA.genKernelGlob "testGlobRev" testGlobRev (GlobalArray undefined (variable "n") :: GlobalArray Pull (Exp Int)) 


vSwap :: (GlobalArray Pull (Exp Int), Exp Word32) -> 
         Kernel (GlobalArray Push (Exp Int)) 
vSwap (arr,stride) = return p5
    
  where 
    t1 ix = ix + (ix .&. (complement (stride - 1)))
    t2 ix = ix `xor` ((stride `shiftL` 1)-1)<commit_msg>swoosch<commit_after>
module Examples2 where 

import Obsidian.GCDObsidian

import qualified Obsidian.GCDObsidian.CodeGen.CUDA as CUDA
import qualified Obsidian.GCDObsidian.CodeGen.C as C
import qualified Obsidian.GCDObsidian.CodeGen.OpenCL as CL

import Obsidian.GCDObsidian.Program

import Data.Word
import Data.Bits

import Prelude hiding (zipWith)

----------------------------------------------------------------------------
--

test1 :: GlobalArray Pull (Exp Int) -> Kernel (GlobalArray Push (Exp Int)) 
test1 = pure (block 256) ->- pure (fst . halve) ->- 
        pure (unblock . push) 

getTest1 = putStrLn$ CUDA.genKernelGlob "test1" test1 (GlobalArray undefined (variable "n"):: GlobalArray Pull (Exp Int)) 


testParam1 :: (GlobalArray Pull (Exp Int), Exp Int) -> Kernel (GlobalArray Push (Exp Int)) 
testParam1 (garr, param) = res
  where 
    res = test1$ fmap (+param) garr 

getTestParam1 = putStrLn$ CUDA.genKernelGlob "testParam1" testParam1 (GlobalArray undefined (variable "n") :: GlobalArray Pull (Exp Int),variable "v") 


globRev (GlobalArray (Pull ixf) n) = GlobalArray (Pull (\ix -> ixf (n - 1 - ix))) n

testGlobRev = pure globRev ->- 
              pure (block 256) ->- 
              pure rev ->- -- also reverse each block 
              pure (unblock . push) 

getTestGlobRev = putStrLn$ CUDA.genKernelGlob "testGlobRev" testGlobRev (GlobalArray undefined (variable "n") :: GlobalArray Pull (Exp Int)) 


vSwap :: (GlobalArray Pull (Exp Int), Exp Word32) -> 
         Kernel (GlobalArray Push (Exp Int)) 
vSwap (arr,stride) = return p5
    
  where 
    t1 ix = ix + (ix .&. (complement (stride - 1)))
    t2 ix = ix `xor` ((stride `shiftL` 1)-1)
{'fraction_non_alphanumeric': 0.15988994191378783, 'fraction_numerical': 0.01650871293182513, 'mean_word_length': 2.9516908212560384, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5232469', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1043, 'n_words': 337}