Skip to content

Conversation

@glehmann
Copy link
Contributor

@glehmann glehmann commented Mar 5, 2015

clBLAS, clFFT and boost compute were used to be configure and built manually.
They are now built using cmake's external projects, and linked statically.
The system installed packages can also be used by setting the corresponding
USE_SYSTEM_ option to ON.
This also fix a possible conflict with clBLAS and clFFT when installing these
project shared libraries from arrayfire

see #453

@glehmann
Copy link
Contributor Author

glehmann commented Mar 5, 2015

Please do not merge yet: it depends on clMathLibraries/clBLAS#67 for the static build, and clMathLibraries/clFFT#68 and clMathLibraries/clBLAS#68 to find an installed version of these libs.

@pavanky
Copy link
Member

pavanky commented Mar 5, 2015

@glehmann We need to be a bit mindful about how it affects Windows builds. Do you have a windows machine handy that you can test this on ?

@glehmann
Copy link
Contributor Author

glehmann commented Mar 6, 2015

@pavanky I only have a VM with windows 7, and no opencl installed on it. Is it possible to install opencl in a VM?

@pavanky
Copy link
Member

pavanky commented Mar 6, 2015

@glehmann It is fine. We'll test it out once the Pull requests for clMath go through.

@glehmann glehmann force-pushed the build-opencl-dependencies branch from ba75697 to cdf437b Compare March 8, 2015 08:04
pavanky referenced this pull request in glehmann/arrayfire Mar 8, 2015
so arrayfire can be used in a cmake project with the usual find_package command

  find_package(arrayfire REQUIRED)
  include_directories(${ARRAYFIRE_INCLUDE_DIRS})
  tarkget_link_libraries(mytarget ${ARRAYFIRE_LIBRARIES})
@9prady9
Copy link
Member

9prady9 commented Mar 10, 2015

👍 good learning for me about CMake. thanks @glehmann

@kknox
Copy link

kknox commented Mar 12, 2015

I merged the PR's mentioned above by @glehmann. gtg.

@pavanky
Copy link
Member

pavanky commented Mar 13, 2015

@glehmann We are doing a beta (binary) release today. We'll be merging this after the release is done.

@glehmann glehmann force-pushed the build-opencl-dependencies branch from cdf437b to 1969fc3 Compare March 14, 2015 04:51
@pavanky
Copy link
Member

pavanky commented Mar 24, 2015

@glehmann I am getting the following error when trying to build a fresh clone of your branch

CMake Error at src/backend/opencl/CMakeLists.txt:17 (FIND_PACKAGE):
  By not providing "FindclBLAS.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "clBLAS", but
  CMake did not find one.

  Could not find a package configuration file provided by "clBLAS" with any
  of the following names:

    clBLASConfig.cmake
    clblas-config.cmake

  Add the installation prefix of "clBLAS" to CMAKE_PREFIX_PATH or set
  "clBLAS_DIR" to a directory containing one of the above files.  If "clBLAS"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

@pavanky
Copy link
Member

pavanky commented Mar 24, 2015

The problem is with USE_SYSTEM_* being set to ON by default. Can you set it to off ?

Also when set to ON, it would be better if user had to specify the root paths manually rather than CMake trying to find "FindclBLAS.cmake"

@glehmann
Copy link
Contributor Author

I'll set it to OFF by default. Having it to ON by default helps to identify the dependencies for the packagers, but I understand that this is much more convenient for the users and the developers when set to OFF by default.

The message is automatically generated by find_package and I have no control over it. I would also prefer if a less obvious reference to the FindclBLAS.cmake…

And the user indeed has to set clFFT_DIR and clBLAS_DIR by hand when the USE_SYSTEM_* are set to ON and clBLAS and clFFT can't be found automatically.

@glehmann glehmann force-pushed the build-opencl-dependencies branch from 1969fc3 to 8c05ce0 Compare March 24, 2015 19:31
@glehmann
Copy link
Contributor Author

I've updated the pull request. Please try it on windows before merging — I didn't have a chance to test it on this platform.

@pavanky
Copy link
Member

pavanky commented Mar 24, 2015

@glehmann The examples for clFFT were added recently and they don't seem to compile with the static libraries on windows and linux. I reported the issue here: clMathLibraries/clFFT#74

I may have a quick solution for Linux but the windows one will take some time to figure out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this GIT_TAG necessary or can we simply use HEAD always? We would prefer having HEAD.
Also, can you change the repository URL to point to https://github.com/arrayfire/clBLAS.git

Same changes for clFFT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if the tag is necessary, but it is a good idea to keep it in my opinion: it ensures that the version used is the expected one at the time the code was written, a bit like having clBLAS and clFFT directly in the repository or in a submodule.

clBLAS, clFFT and boost compute were used to be configure and built manually.
They are now built using cmake's external projects, and linked statically.
The system installed packages can also be used by setting the corresponding
USE_SYSTEM_<package> option to ON.
This also fix a possible conflict with clBLAS and clFFT when installing these
project shared libraries from arrayfire

see arrayfire#453
@glehmann glehmann force-pushed the build-opencl-dependencies branch from 8c05ce0 to 6be994e Compare March 25, 2015 17:36
@glehmann
Copy link
Contributor Author

I've updated the PR to use arrayfire's repositories for clFFT and clBLAS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glehmann can you add ADD_DEFINITIONS( -DCLFFT_BUILD_STATIC ) here (also any check required around it). This is needed to disable the dll exports on Windows. Otherwise when clfft.h is included in ArrayFire source, the dll definitions will be there and thats what is causing issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-(

We really shouldn't have to do this - I'll think a bit more about clMathLibraries/clFFT#75 to see if it can be done directly there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clBLAS is not using the __dlexport and __dlimport routines. I am not entirely sure if clFFT needs them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this quickly in clFFT (by removing the macro conditions and just keeping #define CLFFTAPI (to keep the compiler happy) and it worked fine. all the examples ran ok.

I can go ahead and push this is all parties agree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah well, may have spoken too soon. Shared libs aren't playing too well with that. I guess for now we can just add the definitions in ArrayFire until we figure out a solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. after a little bit of research it looks like clBLAS does export it, except not in the standard way.
It uses a .def file (https://github.com/arrayfire/clBLAS/blob/develop/src/clBLAS.def) to export the symbols in case of shared libs. Because such a file does not exist for clFFT, the declspecs are required.

And according to this http://www.cmake.org/cmake/help/v3.0/command/add_library.html, if add_library does not specify SHARED or STATIC, then the value of BUILD_SHARED_LIBS is used to determine shared. And this is exactly the case in clBLAS.

@shehzan10
Copy link
Member

Merged in #550

@shehzan10 shehzan10 closed this Mar 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants