Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

split accelerate-io package

Conflicts:

	accelerate.cabal
  • Loading branch information...
commit 5fc239bc64360464f5231f27c67889afbf16b31a 1 parent ca68524
Trevor L. McDonell tmcdonell authored mchakravarty committed
1  .gitignore
View
@@ -6,3 +6,4 @@
/accelerate-cuda/config.log
/accelerate-cuda/config.status
/accelerate-cuda/cubits/accelerate_cuda_shape.h
+/accelerate-io/dist/
0  Data/Array/Accelerate/IO.hs → accelerate-io/Data/Array/Accelerate/IO.hs
View
File renamed without changes
0  Data/Array/Accelerate/IO/BlockCopy.hs → accelerate-io/Data/Array/Accelerate/IO/BlockCopy.hs
View
File renamed without changes
0  Data/Array/Accelerate/IO/ByteString.hs → accelerate-io/Data/Array/Accelerate/IO/ByteString.hs
View
File renamed without changes
0  Data/Array/Accelerate/IO/Ptr.hs → accelerate-io/Data/Array/Accelerate/IO/Ptr.hs
View
File renamed without changes
110 accelerate-io/Data/Array/Accelerate/Internal/Check.hs
View
@@ -0,0 +1,110 @@
+{-# LANGUAGE CPP #-}
+-- |
+-- Module : Data.Array.Accelerate.Internal.Check
+-- Copyright : [2009..2011] Roman Lechinskiy, Trevor L. McDonell
+-- License : BSD3
+--
+-- Maintainer : Manuel M T Chakravarty <chak@cse.unsw.edu.au>
+-- Stability : experimental
+-- Portability : non-portable (GHC extensions)
+--
+-- Bounds checking infrastructure
+--
+-- Stolen from the Vector package by Roman Leshchinskiy. This code has a
+-- BSD-style license. <http://hackage.haskell.org/package/vector>
+--
+
+module Data.Array.Accelerate.Internal.Check (
+
+ -- * Bounds checking and assertion infrastructure
+ Checks(..), doChecks,
+ error, check, assert, checkIndex, checkLength, checkSlice
+
+) where
+
+import Prelude hiding( error )
+import qualified Prelude as P
+
+data Checks = Bounds | Unsafe | Internal deriving( Eq )
+
+doBoundsChecks :: Bool
+#ifdef ACCELERATE_BOUNDS_CHECKS
+doBoundsChecks = True
+#else
+doBoundsChecks = False
+#endif
+
+doUnsafeChecks :: Bool
+#ifdef ACCELERATE_UNSAFE_CHECKS
+doUnsafeChecks = True
+#else
+doUnsafeChecks = False
+#endif
+
+doInternalChecks :: Bool
+#ifdef ACCELERATE_INTERNAL_CHECKS
+doInternalChecks = True
+#else
+doInternalChecks = False
+#endif
+
+
+doChecks :: Checks -> Bool
+{-# INLINE doChecks #-}
+doChecks Bounds = doBoundsChecks
+doChecks Unsafe = doUnsafeChecks
+doChecks Internal = doInternalChecks
+
+error :: String -> Int -> Checks -> String -> String -> a
+error file line kind loc msg
+ = P.error . unlines $
+ (if kind == Internal
+ then ([""
+ ,"*** Internal error in package accelerate ***"
+ ,"*** Please submit a bug report at https://github.com/mchakravarty/accelerate/issues"]++)
+ else id)
+ [ file ++ ":" ++ show line ++ " (" ++ loc ++ "): " ++ msg ]
+
+check :: String -> Int -> Checks -> String -> String -> Bool -> a -> a
+{-# INLINE check #-}
+check file line kind loc msg cond x
+ | not (doChecks kind) || cond = x
+ | otherwise = error file line kind loc msg
+
+assert_msg :: String
+assert_msg = "assertion failure"
+
+assert :: String -> Int -> Checks -> String -> Bool -> a -> a
+{-# INLINE assert #-}
+assert file line kind loc = check file line kind loc assert_msg
+
+checkIndex_msg :: Int -> Int -> String
+{-# NOINLINE checkIndex_msg #-}
+checkIndex_msg i n = "index out of bounds " ++ show (i,n)
+
+checkIndex :: String -> Int -> Checks -> String -> Int -> Int -> a -> a
+{-# INLINE checkIndex #-}
+checkIndex file line kind loc i n x
+ = check file line kind loc (checkIndex_msg i n) (i >= 0 && i<n) x
+
+
+checkLength_msg :: Int -> String
+{-# NOINLINE checkLength_msg #-}
+checkLength_msg n = "negative length " ++ show n
+
+checkLength :: String -> Int -> Checks -> String -> Int -> a -> a
+{-# INLINE checkLength #-}
+checkLength file line kind loc n x
+ = check file line kind loc (checkLength_msg n) (n >= 0) x
+
+
+checkSlice_msg :: Int -> Int -> Int -> String
+{-# NOINLINE checkSlice_msg #-}
+checkSlice_msg i m n = "invalid slice " ++ show (i,m,n)
+
+checkSlice :: String -> Int -> Checks -> String -> Int -> Int -> Int -> a -> a
+{-# INLINE checkSlice #-}
+checkSlice file line kind loc i m n x
+ = check file line kind loc (checkSlice_msg i m n)
+ (i >= 0 && m >= 0 && i+m <= n) x
+
24 accelerate-io/LICENSE
View
@@ -0,0 +1,24 @@
+Copyright (c) [2007..2009] Manuel M T Chakravarty, Gabriele Keller, Sean Lee &
+Trevor L. McDonell, University of New South Wales. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the University of New South Wales nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 accelerate-io/accelerate-io.cabal
View
@@ -0,0 +1,59 @@
+Name: accelerate-io
+Version: 0.9.0.0
+Cabal-version: >= 1.6
+Tested-with: GHC >= 6.12.3
+Build-type: Simple
+
+Synopsis: Low-level conversions between Accelerate arrays
+Description: Low-level conversions between Accelerate arrays
+
+License: BSD3
+License-file: LICENSE
+Author: Manuel M T Chakravarty,
+ Gabriele Keller,
+ Sean Lee,
+ Trevor L. McDonell
+Maintainer: Manuel M T Chakravarty <chak@cse.unsw.edu.au>
+Homepage: http://www.cse.unsw.edu.au/~chak/project/accelerate/
+Bug-reports: https://github.com/mchakravarty/accelerate/issues
+
+Category: Compilers/Interpreters, Concurrency, Data
+Stability: Experimental
+
+Extra-source-files: include/accelerate.h
+
+Flag bounds-checks
+ Description: Enable bounds checking
+ Default: True
+
+Flag unsafe-checks
+ Description: Enable bounds checking in unsafe operations
+ Default: False
+
+Flag internal-checks
+ Description: Enable internal consistency checks
+ Default: False
+
+Library
+ Include-Dirs: include
+ Build-depends: accelerate == 0.9.*,
+ bytestring == 0.9.*,
+ array == 0.3.*,
+ base == 4.*
+
+ Other-modules: Data.Array.Accelerate.IO.BlockCopy
+ Exposed-modules: Data.Array.Accelerate.IO
+ Data.Array.Accelerate.IO.Ptr
+ Data.Array.Accelerate.IO.ByteString
+
+ if flag(bounds-checks)
+ cpp-options: -DACCELERATE_BOUNDS_CHECKS
+
+ if flag(unsafe-checks)
+ cpp-options: -DACCELERATE_UNSAFE_CHECKS
+
+ if flag(internal-checks)
+ cpp-options: -DACCELERATE_INTERNAL_CHECKS
+
+ ghc-options: -O2 -Wall -funbox-strict-fields
+
25 accelerate-io/include/accelerate.h
View
@@ -0,0 +1,25 @@
+
+#ifndef NOT_ACCELERATE_MODULE
+import qualified Data.Array.Accelerate.Internal.Check as Ck
+#endif
+
+#define ERROR(f) (Ck.f __FILE__ __LINE__)
+#define ASSERT (Ck.assert __FILE__ __LINE__)
+#define ENSURE (Ck.f __FILE__ __LINE__)
+#define CHECK(f) (Ck.f __FILE__ __LINE__)
+
+#define BOUNDS_ERROR(f) (ERROR(f) Ck.Bounds)
+#define BOUNDS_ASSERT (ASSERT Ck.Bounds)
+#define BOUNDS_ENSURE (ENSURE Ck.Bounds)
+#define BOUNDS_CHECK(f) (CHECK(f) Ck.Bounds)
+
+#define UNSAFE_ERROR(f) (ERROR(f) Ck.Unsafe)
+#define UNSAFE_ASSERT (ASSERT Ck.Unsafe)
+#define UNSAFE_ENSURE (ENSURE Ck.Unsafe)
+#define UNSAFE_CHECK(f) (CHECK(f) Ck.Unsafe)
+
+#define INTERNAL_ERROR(f) (ERROR(f) Ck.Internal)
+#define INTERNAL_ASSERT (ASSERT Ck.Internal)
+#define INTERNAL_ENSURE (ENSURE Ck.Internal)
+#define INTERNAL_CHECK(f) (CHECK(f) Ck.Internal)
+
18 accelerate.cabal
View
@@ -88,11 +88,8 @@ Flag internal-checks
Description: Enable internal consistency checks
Default: False
-Flag io
- Description: Provide access to the block copy I/O functionality
- Default: False
-
Library
+ Include-Dirs: include
Build-depends: array >= 0.3 && < 0.5,
base == 4.*,
containers >= 0.3 && < 0.5,
@@ -100,15 +97,9 @@ Library
ghc-prim == 0.2.*,
pretty >= 1.0 && < 1.2
- Include-Dirs: include
-
if flag(llvm)
Build-depends: llvm >= 0.6.8
- if flag(io)
- Build-depends: bytestring == 0.9.*,
- vector == 0.9.*
-
-- if flag(test-suite)
-- Build-depends: QuickCheck == 2.*
@@ -135,13 +126,6 @@ Library
-- If flag(llvm)
-- Exposed-modules: Data.Array.Accelerate.LLVM
- if flag(io)
- Other-modules: Data.Array.Accelerate.IO.BlockCopy
- Exposed-modules: Data.Array.Accelerate.IO
- Data.Array.Accelerate.IO.Ptr
- Data.Array.Accelerate.IO.ByteString
- Data.Array.Accelerate.IO.Vector
-
-- If flag(test-suite)
-- Exposed-modules: Data.Array.Accelerate.Test
-- Other-modules: Data.Array.Accelerate.Test.QuickCheck
Please sign in to comment.
Something went wrong with that request. Please try again.