Merge PR #251 for updating opencl support using ViennaCL
Conflicts:
doc/en/docs/installation.md
Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/1996e8a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/1996e8a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/1996e8a9
Branch: refs/heads/master
Commit: 1996e8a950f6c204cbc418ca1737cbfe752998ad
Parents: 61ec2ec 5380b3a
Author: Wei Wang <[email protected]>
Authored: Wed Aug 31 12:34:17 2016 +0800
Committer: Wei Wang <[email protected]>
Committed: Wed Aug 31 12:34:17 2016 +0800
----------------------------------------------------------------------
.travis.yml | 6 +-
CMakeLists.txt | 3 +-
LICENSE | 4 +-
cmake/Dependencies.cmake | 25 +-
cmake/Thirdparty/FindViennaCL.cmake | 45 ++
doc/en/docs/installation.md | 23 +
include/singa/core/common.h | 10 +-
include/singa/core/device.h | 56 +-
include/singa/utils/opencl_utils.h | 142 +---
src/core/device/opencl_device.cc | 182 ++---
src/core/tensor/tensor_math_opencl.cl | 19 +-
src/core/tensor/tensor_math_opencl.h | 1007 ++++++++--------------------
src/utils/opencl_utils.cc | 63 --
test/singa/test_opencl.cc | 700 ++++++++-----------
test/singa/test_opencl_device.cc | 108 +++
15 files changed, 845 insertions(+), 1548 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/1996e8a9/cmake/Dependencies.cmake
----------------------------------------------------------------------
diff --cc cmake/Dependencies.cmake
index 5fb7578,aa2212b..a412151
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@@ -55,23 -55,26 +55,26 @@@ ENDIF(
IF(USE_OPENCL)
FIND_PACKAGE(OpenCL REQUIRED)
- IF(NOT OPENCL_FOUND)
+ IF(NOT OpenCL_FOUND)
MESSAGE(SEND_ERROR "OpenCL was requested, but not found.")
ELSE()
- INCLUDE_DIRECTORIES(SYSTEM ${OpenCL_INCPATH})
- LIST(APPEND SINGA_LINKER_LIBS ${OPENCL_LIBRARIES})
- MESSAGE(STATUS "Found OpenCL at ${OPENCL_INCLUDE_DIRS}")
- IF(NOT OPENCL_HAS_CPP_BINDINGS)
- MESSAGE(SEND_ERROR "OpenCL C++ bindings cl2.hpp was not found.")
- ELSE()
- MESSAGE(STATUS "Found OpenCL C++ bindings.")
- ENDIF()
- ENDIF()
+ MESSAGE(STATUS "Found OpenCL headers at ${OpenCL_INCLUDE_DIRS}")
+ INCLUDE_DIRECTORIES(SYSTEM ${OpenCL_INCLUDE_DIR})
+ LIST(APPEND SINGA_LINKER_LIBS ${OpenCL_LIBRARIES})
+ FIND_PACKAGE(ViennaCL REQUIRED)
+ IF(NOT ViennaCL_FOUND)
+ MESSAGE(SEND_ERROR "ViennaCL is required if OpenCL is
enabled.")
+ ELSE()
+ MESSAGE(STATUS "Found ViennaCL headers at
${ViennaCL_INCLUDE_DIR}")
+ INCLUDE_DIRECTORIES(SYSTEM ${ViennaCL_INCLUDE_DIR})
+ LIST(APPEND SINGA_LINKER_LIBS ${ViennaCL_LIBRARIES})
+ ENDIF()
+ ENDIF()
ENDIF()
-FIND_PACKAGE(Glog REQUIRED)
-INCLUDE_DIRECTORIES(SYSTEM ${GLOG_INCLUDE_DIRS})
-LIST(APPEND SINGA_LINKER_LIBS ${GLOG_LIBRARIES})
+#FIND_PACKAGE(Glog REQUIRED)
+#INCLUDE_DIRECTORIES(SYSTEM ${GLOG_INCLUDE_DIRS})
+#LIST(APPEND SINGA_LINKER_LIBS ${GLOG_LIBRARIES})
#MESSAGE(STATUS "Found glog at ${GLOG_INCLUDE_DIRS}")
IF(USE_OPENCV)
http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/1996e8a9/doc/en/docs/installation.md
----------------------------------------------------------------------
diff --cc doc/en/docs/installation.md
index 08508dc,ecf3e97..a8b0530
--- a/doc/en/docs/installation.md
+++ b/doc/en/docs/installation.md
@@@ -9,13 -9,14 +9,14 @@@
### Optional
-* glog
-* opencv (tested with 2.4.8)
-* lmdb (tested with 0.9)
* cuda (tested with 6.5, 7.0 and 7.5)
* cudnn (v4 and v5)
+* opencv (tested with 2.4.8)
+* lmdb (tested with 0.9)
+* glog
+ * opencl-headers and viennacl (version 1.7.1 or newer) for OpenCL support
-PySINGA has additional dependencies
+PySINGA (the Python binding) has additional dependencies
* python(==2.7)
* pip(>=1.5)
@@@ -191,6 -147,28 +192,28 @@@ After compiling SINGA, you can run the
You can see all the testing cases with testing results. If SINGA passes all
tests, then you have successfully installed SINGA. Please proceed to try the
examples!
+ ### OpenCL support (Linux)
+
+ Install `opencl-headers` and `libviennacl-dev` (Ubuntu 16) or `viennacl`
(Fedora).
+
+ Additionally, you will need the OpenCL Installable Client Driver (ICD) for
the platforms that you want to run OpenCL on.
+
+ * For AMD and nVidia GPUs, the driver package should also install the correct
OpenCL ICD.
+ * For Intel CPUs and/or GPUs, get the driver from the [Intel
website.](https://software.intel.com/en-us/articles/opencl-drivers) Note that
the drivers provided on that website only supports recent CPUs and Iris GPUs.
+ * For older Intel CPUs, you can use the `beignet-opencl-icd` package.
+
+ Note that running OpenCL on CPUs is not currently recommended because it is
slow. Memory transfer is on the order of whole seconds (1000's of ms on CPUs as
compared to 1's of ms on GPUs).
+
+ More information on setting up a working OpenCL environment may be found
[here](https://wiki.tiker.net/OpenCLHowTo).
+
+ If the package version of ViennaCL is not at least 1.7.1, you will need to
build it from source:
+
+ Clone [the repository from here](https://github.com/viennacl/viennacl-dev),
checkout the `release-1.7.1` tag and build it.
+ Remember to add its directory to `PATH` and the built libraries to
`LD_LIBRARY_PATH`.
+
+ To build SINGA with OpenCL support, you need to pass the flag during cmake:
-
++
+ cmake .. -DUSE_OPENCL=ON
### Windows
To be added.