Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    statusfailed
    @statusfailed_gitlab

    I'm getting a weird linker error with accelerate-blas when using cabal repl but not cabal build. Here's an example project: https://github.com/statusfailed/scratch-accelerate-blas/
    I get this error with cabal repl:

    <command line>: /home/me/.cabal/store/ghc-8.8.4/cublas-0.6.0.0-8ca4167aa294815e880fa35fed831c35a0190555bf76b4606fb8da7913924d2d/lib/libHScublas-0.6.0.0-8ca4167aa294815e880fa35fed831c35a0190555bf76b4606fb8da7913924d2d-ghc8.8.4.so: undefined symbol: _ZSt7nothrow
    cabal: repl failed for exe:scratch-accelerate-blas from
    scratch-accelerate-blas-0.1.0.0.

    It seems like cublas isn't building properly, but what's weird is that I can do "cabal repl" in the cublas project just fine- any ideas how I can debug this?

    statusfailed
    @statusfailed_gitlab
    Actually it seems like the problem might be accelerate-blas, I get (basically) the same error with stack replin that project- it complains about missing symbol _ZTVN10__cxxabiv121__vmi_class_type_infoE but it's also missing _ZSt7nothrow
    statusfailed
    @statusfailed_gitlab
    Apparently GHCi's linker is different to GHCs linker, so I guess that explains why cabal build works and cabal repl doesn't
    Seems like these symbols are from libstdc++, and it seems like GHCi has trouble with linking to this, but I don't really understand why or how to fix it
    statusfailed
    @statusfailed_gitlab
    Does anyone else get this linker error when repling with accelerate-blas, or is it just me?
    Logan Leland
    @loganleland
    statusfailed
    @statusfailed_gitlab
    yeah
    are you able to cabal repl in the root of that project?
    Logan Leland
    @loganleland
    It looks like I need to grab a few dependencies first - I'll try to give it a go tonight
    if you're familiar with containers you could try to use nvidia-docker or something else to see if you can get it working there
    statusfailed
    @statusfailed_gitlab
    oh neat, I didn't know about that
    I'll give that a shot, thanks
    Trevor L. McDonell
    @tmcdonell

    @loganleland I don't think there is a specific pattern, but here is one using replicate:

    allpairs :: Elt a => Acc (Vector a) -> Acc (Matrix (a,a))
    allpairs xs =
      let I1 n = shape xs
       in zip (replicate (lift (Z :. n :. All)) xs)
              (replicate (lift (Z :. All :. n)) xs)

    or based on your description above here is something that uses a scalar inner loop (not sure if this is what you meant though):

    hom :: (Num a, Num b, Eq b) => (Exp a -> Exp b) -> Acc (Vector a) -> Acc (Scalar Bool)
    hom f xs =
      let I1 n = shape xs
       in and
        $ map (\x -> let fx = f x
                      in snd $ while (\(T2 i r) -> i < n && r)
                                     (\(T2 i _) -> let y = xs !! i
                                                    in T2 (i+1) (f (x + y) == fx + f y))
                                     (T2 0 True_)) xs
    Logan Leland
    @loganleland
    Thanks Trevor, I will use this allpairs in my Utility module!
    statusfailed
    @statusfailed_gitlab
    @tmcdonell any idea about the linker error above? I just ran into it again when trying to use TemplateHaskell which is kinda weird
    I guess templatehaskell uses the ghci linker
    Trevor L. McDonell
    @tmcdonell
    template haskell is run through ghci, yes. I haven’t had a chance to look at it yet but it is possible we need to specify different libraries for compiled & interpreted mode (we need to do that for the base CUDA bindings already for example)
    statusfailed
    @statusfailed_gitlab
    Ah, does that happen in the Setup.hs of the cuda package?
    I saw there were some notes on windows / OSX compatibility but I wasn't sure if they applied to linux
    Trevor L. McDonell
    @tmcdonell
    yes, in Setup.hs. Linux is usually the simplest to get working, I’ll have to dig in more.
    statusfailed
    @statusfailed_gitlab
    @tmcdonell I just ran into a bug (I think) with the PTX backend when slicing an array with a Scalar Int. I reported it AccelerateHS/accelerate-llvm#67 but I don't seem to have this nvidia-device-query program on my system- where do I get it?
    statusfailed
    @statusfailed_gitlab
    also lmk if I can do anything to help with the linker problem, I wasn't really sure how to progress but I'm happy to test stuff if it helps :-)
    Trevor L. McDonell
    @tmcdonell
    the program is part of the CUDA bindings package so it should be wherever stack/cabal installs things. I’m still away on vacation this week but will try and look when I get back!
    statusfailed
    @statusfailed_gitlab
    No rush- thanks for taking a look- enjoy your holiday!
    Logan Leland
    @loganleland
    Hi everyone, has anyone written a big numeric to extend the lengths of the base types in the Exp language making use of the tuples? I haven't written this yet - though I will for at least int and float
    Trevor L. McDonell
    @tmcdonell
    do you mean something like accelerate-bignum for 128-bit etc. integers?
    Logan Leland
    @loganleland
    exactly, thanks for pointing this out to me (I should have looked harder). I only checked out the examples if this existed
    Trevor L. McDonell
    @tmcdonell
    there is no equivalent for floating point but if you make one let me know (:
    Logan Leland
    @loganleland
    Hey everyone, I see that in general an Exp a cannot be unlifted to an a. I'm currently looking for an implementation of a maybeTail (Nothing is vector is null Just otherwise). Here's the type I'm after
    maybeTail :: Elt a => Acc (Vector a) -> Maybe (Acc (Vector a))
    Does anyone have something along these lines?
    Logan Leland
    @loganleland
    Maybe if this isn't a natural thing to do in the Exp/Acc language - my purpose is to write an intersection function of this type: intersection :: (Elt a, Eq a) => Acc (Vector a) -> Acc (Vector a) -> Acc (Vector a) that works as set intersection
    Trevor L. McDonell
    @tmcdonell
    yes, we don't have pattern matching in the Acc language (yet), although I have been thinking of adding it (I don't think there are any fundamental limitations, just a lack of time)
    you did manage to nerd-snipe me though, so I added intersection/difference/union to the map and set in https://github.com/tmcdonell/containers-accelerate
    Logan Leland
    @loganleland
    That's great, thanks! I'm going to see if I can use this as an inspiration to get it over the Acc (Vector a) type. I'm also considering now to switch my codebase over to HashSet.
    I understand the lack of time, my teaching and class obligations have picked up just a few weeks ago now
    Trevor L. McDonell
    @tmcdonell
    yeah, this was a nice distraction from those obligations 😅
    Logan Leland
    @loganleland
    Does anyone have a sequential filter over Acc (Vector a)'s by chance?
    Trevor L. McDonell
    @tmcdonell
    why sequential?
    Logan Leland
    @loganleland
    Let me send a small example program of the use case after an algebra exam I have tonight :D
    Trevor L. McDonell
    @tmcdonell
    good luck for your exam! :D
    Logan Leland
    @loganleland
    Thanks for the luck, it went quite good. Here's a small example program of why I (think) I could use a sequential filter in a nice way
    import Data.Array.Accelerate              as A
    import Data.Array.Accelerate.LLVM.PTX     as GPU 
    
    member :: (Elt a, A.Eq a) => Acc (Vector a) -> Exp a -> Exp Bool
    member vec x = the $ A.any (x A.==) vec 
    
    xs = fromList (Z:.10) [0..]   :: Vector Int 
    ys = fromList (Z:.10) [1,3..] :: Vector Int 
    
    main =
      print $ GPU.run $ A.filter (member $ use ys) (use xs)
    Logan Leland
    @loganleland
    Of course I'm not even sure with a sequential filter if this would optimize well
    Trevor L. McDonell
    @tmcdonell
    for something like this you can use a (sequential) loop with while, or it’s derivatives like sfoldl
    Logan Leland
    @loganleland
    Hello, for accelerate-llvm-ptx >= 1.3, is libNVVM required? On https://github.com/AccelerateHS/accelerate-llvm#dependencies it says it is optional to use over LLVMs inbuilt NVPTX code generator.
    Trevor L. McDonell
    @tmcdonell
    libNVVM will be included as part of your CUDA installation, the flag is whether or not to use it as part of the optimiser when compiling the code (which is not necessary)
    Logan Leland
    @loganleland
    Thanks! I'll try out both when I start benchmarking. I had some trouble with getting things building for execution on a fresh arch install but I got it!
    Trevor L. McDonell
    @tmcdonell
    you might have trouble with cuda-11? I haven't had a chance to update the cuda bindings package for that
    Logan Leland
    @loganleland
    I went with 10.2 just to be safe
    I just had to move files around a bit from both the LLVM install and the cuda install