Skip to content

Instantly share code, notes, and snippets.

View tmcdonell's full-sized avatar
🐙
coalescing

Trevor L. McDonell tmcdonell

🐙
coalescing
View GitHub Profile
import LLVM.General.Context
import LLVM.General.Module as LLVM
import LLVM.General.Target
import LLVM.General.ExecutionEngine
import LLVM.General.PassManager
import LLVM.General.AST.Name ( Name(..) )
import LLVM.General.AST.DataLayout ( DataLayout, Endianness(..), defaultDataLayout )
import Control.Monad
@tmcdonell
tmcdonell / Main.hs
Created October 21, 2015 21:56
Memory leak / performance regression with Accelerate
module Main (main) where
import Control.Monad
import Data.Array.Accelerate as A hiding ((++),(>->))
import Data.Array.Accelerate.CUDA
import Data.Array.Accelerate.IO as A
import Data.Vector.Storable as S
> stack setup --upgrade-cabal --verbose
Version 0.1.4.0, Git revision dac8cfe51802e08edb523b80c51cf35e21933513 (1722 commits) X86_64
2015-09-21 14:35:46.098374: [debug] Checking for project config at: /Users/trevor/Dropbox/Projects/stack-bug/stack.yaml @(stack_256QTnIkPXj66qDsz01mSu:Stack.Config src/Stack/Config.hs:466:9)
2015-09-21 14:35:46.101455: [debug] Loading project config file stack.yaml @(stack_256QTnIkPXj66qDsz01mSu:Stack.Config src/Stack/Config.hs:489:13)
2015-09-21 14:35:46.102182: [debug] Trying to decode /Users/trevor/.stack/build-plan-cache/x86_64-osx/lts-2.22.cache @(stack_256QTnIkPXj66qDsz01mSu:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:77:5)
2015-09-21 14:35:46.107005: [debug] Success decoding /Users/trevor/.stack/build-plan-cache/x86_64-osx/lts-2.22.cache @(stack_256QTnIkPXj66qDsz01mSu:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:86:13)
2015-09-21 14:35:46.107324: [debug] Run process: ghc --info @(stack_256QTnIkPXj66qDsz01mSu:System.Process.Read src/System/Proc
fib 10: 969 terms
benchmarking fib/10/down/manual
time 10.90 μs (10.77 μs .. 11.02 μs)
0.999 R² (0.998 R² .. 0.999 R²)
mean 10.84 μs (10.72 μs .. 10.97 μs)
std dev 445.2 ns (367.4 ns .. 545.6 ns)
variance introduced by outliers: 50% (severely inflated)
benchmarking fib/10/down/ghostbuster
time 17.23 μs (17.09 μs .. 17.41 μs)
@tmcdonell
tmcdonell / gist:b385e1b8676348509dc8
Created July 7, 2015 06:03
lowerDicts $ ghostbuster feldspar_gadt nothing
-- pretty :: PP.Pretty a => a -> String
-- pretty = PP.prettyPrintStyleMode style mode
-- where
-- mode = PP.defaultMode { PP.classIndent = 2, PP.whereIndent = 2, PP.caseIndent = 2, PP.layout = PP.PPOffsideRule }
-- style = PP.style { PP.mode = PP.PageMode, PP.lineLength = 1000 }
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- {-# OPTIONS_GHC -fdefer-type-errors #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Ghostbuster where
//
// Generated by LLVM NVPTX Back-End
//
.version 3.1
.target sm_30
.address_size 64
// .globl __nv_fminf
.visible .func (.param .b32 func_retval0) fminf
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Prelude as P
import Data.Array.Accelerate as A
ok :: Acc (Vector (Point Float))
-> Acc (Vector (Cluster Float))
-> Acc (Vector (Cluster Float))
//
// Generated by LLVM NVPTX Back-End
//
.version 3.1
.target sm_20
.address_size 64
// .globl map
// @map
; ModuleID = 'map'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-f32:32:32-f64:64:64-n16:32:64"
target triple = "nvptx64-nvidia-cuda"
; Function Attrs: nounwind
define void @map(i64* noalias nocapture %out.ad0, i64 %out.sh0, i64* noalias nocapture readonly %fv0.ad0, i64 %fv0.sh0) #0 {
entry:
%0 = trunc i64 %out.sh0 to i32
%1 = tail call i32 @llvm.nvvm.read.ptx.sreg.nctaid.x() #2
%2 = tail call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() #2