Permalink
Browse files

Added testing of memory object properties and we no longer link with …

…OpenCL, applications using hopencl must do link themself (-lOpenCL)
  • Loading branch information...
1 parent c7d4028 commit 1944a2c656f551c0c0518db427eb7c0b0b9c0e62 @dybber dybber committed Dec 18, 2011
Showing with 44 additions and 6 deletions.
  1. +21 −5 hopencl.cabal
  2. +23 −1 tests/unit/HOpenCL/MemoryObject_Test.hs
View
26 hopencl.cabal
@@ -3,7 +3,7 @@ Version: 0.2.0
Synopsis: Haskell bindings for OpenCL
Category: Foreign
Description: The bindings follows version 1.1 of the OpenCL specification.
- Haddock documentation is available at http://projects.haskell.org/hopencl/
+ Haddock documentation is available at <http://projects.haskell.org/hopencl/>
.
The following sections of the OpenCL specification are not
supported currently:
@@ -40,11 +40,20 @@ Cabal-version: >= 1.10
Extra-source-files: README.md
include/cl_enums.h
+ include/CL/opencl.h
+ include/CL/cl_platform.h
+ include/CL/cl.h
+ include/CL/cl_ext.h
+ include/CL/cl_d3d10.h
+ include/CL/cl_gl.h
+ include/CL/cl_gl_ext.h
-- Unit tests
tests/unit/HOpenCL_Test.hs
tests/unit/Test_Util.hs
tests/unit/HOpenCL/CommandQueue_Test.hs
+ tests/unit/HOpenCL/MemoryObject_Test.hs
+ tests/unit/HOpenCL/Kernel_Test.hs
tests/unit/HOpenCL/Context_Test.hs
tests/unit/HOpenCL/Device_Test.hs
tests/unit/HOpenCL/Platform_Test.hs
@@ -81,20 +90,27 @@ Library
if os(darwin)
cc-options: "-U__BLOCKS__"
- frameworks: OpenCL
- else
- Extra-Libraries: OpenCL
Test-suite unit
Type: exitcode-stdio-1.0
+
hs-source-dirs: tests/unit
Main-is: HOpenCL_Test.hs
Default-language: Haskell98
- GHC-options: -Wall -fno-warn-missing-signatures
+ GHC-options: -Wall -fno-warn-missing-signatures -lOpenCL
Build-Depends: base >=4, QuickCheck >= 2, test-framework >= 0.4.0,
test-framework-quickcheck2, HUnit,
test-framework-hunit, hopencl
+ -- Cabal doesn't seem to parse the following correctly, I therefore
+ -- specify it as -lOpenCL in GHC-options instead
+ --
+ -- if os(darwin)
+ -- Frameworks: OpenCL
+ -- else
+ -- Extra-Libraries: OpenCL
+
+
Source-repository head
type: git
location: http://github.com/HIPERFIT/hopencl
View
24 tests/unit/HOpenCL/MemoryObject_Test.hs
@@ -8,7 +8,7 @@ import Test.Framework (testGroup, buildTest)
import Control.Monad (forM_, forM, liftM)
-import Test_Util
+import Foreign.Storable (sizeOf)
--------------------
-- Test suite --
@@ -17,8 +17,22 @@ tests = testGroup "MemoryObject"
[ testCase "mallocArray & free" test_mallocArray_free
, testCase "allocaArray" test_allocaArray
, testCase "newListArrayLen & peekListArray" test_newListArrayLen_peekListArray
+ , testMemObjectProps
]
+testMemObjectProps = buildTest $ do
+ platforms <- getPlatformIDs
+ devices <- mapM (getDeviceIDs [DeviceTypeAll]) platforms
+ let pds = zip (map ContextPlatform platforms) devices
+ cs <- forM pds $ \(p, ds) -> createContext ds [p] NoContextCallback
+ memobjs <- forM cs $ \ctx -> mallocArray ctx [MemReadWrite] 42 :: IO (MemObject ClFloat)
+ return $ testGroup "MemoryObject property getters"
+ [ testCase "memobjSize" $ mapM_ (test_memobjSize 42) memobjs
+ -- , testCase "memobjHostPtr" $ mapM_ test_memobjHostPtr memobjs
+ -- , testCase "memobjMapCount" $ mapM_ test_memobjMapCount memobjs
+ , testCase "memobjContext" $ mapM_ test_memobjContext (zip memobjs cs)
+ ]
+
list0 :: [ClInt]
list0 = [1..100]
@@ -52,3 +66,11 @@ test_newListArrayLen_peekListArray = do
(mobj, len) <- newListArrayLen context list0
list0' <- peekListArray cq len mobj
list0 @=? list0'
+
+test_memobjSize n memobj = do
+ size' <- memobjSize memobj
+ fromIntegral (n * sizeOf (undefined :: ClFloat)) @=? size'
+
+test_memobjContext (memobj, context) = do
+ context' <- memobjContext memobj
+ context @=? context'

0 comments on commit 1944a2c

Please sign in to comment.