uncomplicate / neanderthal

Fast Clojure Matrix Library
http://neanderthal.uncomplicate.org
Eclipse Public License 1.0
1.06k stars 56 forks source link

`trans!` does not work correctly using opencl #70

Closed pfeodrippe closed 5 years ago

pfeodrippe commented 5 years ago

I'm running

(ns playground
  (:use [uncomplicate.neanderthal core native])
  (:require [uncomplicate.clojurecl.core :as cl]
            [uncomplicate.commons.core :refer [with-release let-release]]
            [uncomplicate.neanderthal.opencl :as opencl]))

(cl/with-default-1
  (with-release [opencl-factory (opencl/opencl-float cl/*context* cl/*command-queue*)]
    (with-release [m1 (ge opencl-factory 3 3 [1 2 3 4 5 6 7 8 9])]
      (trans! m1)
      (transfer m1))))

and the output is

#RealGEMatrix[float, mxn:3x3, layout:column, offset:0]
   ▥       ↓       ↓       ↓       ┓    
   →       1.00    4.00    7.00         
   →       4.00    5.00    8.00         
   →       7.00    8.00    9.00         
   ┗                               ┛    

where it should have been

#RealGEMatrix[float, mxn:3x3, layout:column, offset:0]
   ▥       ↓       ↓       ↓       ┓    
   →       1.00    2.00    3.00         
   →       4.00    5.00    6.00         
   →       7.00    8.00    9.00         
   ┗                               ┛    

while trans works correctly.

blueberry commented 5 years ago

It may be a problem with Apple's (abandoned) OpenCL implementation or Intel's HD, since I can't reproduce it on neither AMD nor Nvidia:

(cl/with-default-1

  (with-release [opencl-factory (opencl/opencl-float cl/*context* cl/*command-queue*)]

    (with-release [m1 (ge opencl-factory 3 3 [1 2 3 4 5 6 7 8 9])]

      (trans! m1)

      (transfer m1))))
#RealGEMatrix[float, mxn:3x3, layout:column, offset:0]
   ▥       ↓       ↓       ↓       ┓    
   →       1.00    2.00    3.00         
   →       4.00    5.00    6.00         
   →       7.00    8.00    9.00         
   ┗                               ┛    
pfeodrippe commented 5 years ago

Apple is a mess... thank you, @blueberry!

Sorry for bringing these problems here.

blueberry commented 5 years ago

Don't worry. This is what issues are for.

pfeodrippe commented 5 years ago

@blueberry Shame on me, this error happens only with the CPU device ("Intel(R) Core(TM) i7-3520M CPU @ 2.90GHzIntel(R) Core(TM) i7-3520M CPU @ 2.90GHz"), not with the HD Graphics 4000.

I was running with the first device and it was the CPU :P

blueberry commented 5 years ago

I can't reproduce with Intel's OpenCL platform and Intel's CPU on Linux. Works as expected...