Samples and Utility libraries#37
Conversation
bashbaug
left a comment
There was a problem hiding this comment.
Thanks for pulling this all together! This is a huge upgrade to the SDK.
I haven't done an in-depth review but I did do a quick skim through the documentation and identified a few issues.
I also managed to build the updated SDK including all samples following the attached build instructions on my Ubuntu install. Getting vcpkg setup wasn't entirely trivial, but once it was done things pretty much "just worked". I flagged the few build warnings I saw.
The biggest issue I have after building and installing is that a lot of samples don't run due to missing libraries (I've installed into my own install directory, underneath the SDK build tree). Should we build the OpenCL utils as a static library or copy it into the same directory as the samples so this is more robust?
bashbaug@bashbaug-nuc:~/git/OpenCL-SDK/install/Release$ ./saxpy
./saxpy: error while loading shared libraries: libOpenCLUtils.so: cannot open shared object file: No such file or directory
I can run the samples out of the build directory, where the executables still have the libs RPATH'd, but this has other problems. Some examples:
saxpy fails with CL_INVALID_VALUE, though I don't see anywhere we are returning this error:
bashbaug@bashbaug-nuc:~/git/OpenCL-SDK/build/bin$ ./saxpy
Selected platform by Intel(R) Corporation
Selected device: Intel(R) HD Graphics 620 [0x5916]
OpenCL C 3.0
Error: CL_INVALID_VALUE
cppsaxpy can't find the kernel source, which is understandable since I am running from the build directory, but it isn't in the install directory either:
bashbaug@bashbaug-nuc:~/git/OpenCL-SDK/build/bin$ ./cppsaxpy
Selected platform: Intel(R) Corporation
Selected device: Intel(R) HD Graphics 620 [0x5916]
Error: Cannot open kernel source: ./saxpy.cl
binaries cannot find the right binary, but I'm not sure how to create it:
bashbaug@bashbaug-nuc:~/git/OpenCL-SDK/build/bin$ ./binaries
Selected platform by Intel(R) Corporation
Selected device: Intel(R) HD Graphics 620 [0x5916]
OpenCL C 3.0
No suitable file Collatz-Intel(R) HD Graphics 620 [0x5916].bin found
Error: CL_INVALID_VALUE
How can we improve the odds that this all "just works" and/or improve diagnostics when an error occurs?
|
@bashbaug I think I know where your woes are coming from (and both are totally legit).
Symlinking the kernels would be awesome, as it follows updates to code in the source tree, but that has many problems too:
if(CMAKE_SYSTEM_NAME MATHCES Windows)
execute_process(COMMAND "mklink ...")
else()
execute_process(COMMAND "ln -s ...")
endif()but even then, symlinking on Windows without admin rights requires developer mode enabled on the system. 🤯 Wow... Ultimately I accepted the fact that running the samples from the build tree requires making the cwd the path to the kernel in the source tree, but if it bugs anyone, pick an item from the above list or the samples should move away from the CWD-relative location of device code. |
|
All samples now execute correctly from the build tree as well as the install tree in both single and multi-config generators. |
bashbaug
left a comment
There was a problem hiding this comment.
Thanks, this is looking a lot better now!
I was able to run all of the samples save histogram on Linux, and I was able to run this one when I manually copied the kernel file to the install directory. I wasn't able to test the CL-GL sharing samples because we don't support the interop extensions on Linux, but I was able to verify that they run and do not have any missing libraries.
I'm having trouble building on Windows though. I think this is a problem on my end related to vcpkg (the OpenCL-SDK project still can't find TCLAP), but it hasn't been as smooth as Linux. I'll try more tomorrow, since we do support the interop extensions on Windows.
bashbaug
left a comment
There was a problem hiding this comment.
I've been able to successfully build and run all apps on both Windows and Linux - thanks @MathiasMagnus for all of your help getting this working!
For record keeping, the issues I was having on Windows were:
- vcpkg was defaulting to the 32-bit x86 packages instead of the 64-bit x64 packages. Fixed by explicitly specifying
--triplet x64-windowsfor vpkg (see a64a4cb). - After this, the samples built, but not all DLLs were being properly copied to the output directory. Fixed by updating my cmake version (see 9dd7c32).
alycm
left a comment
There was a problem hiding this comment.
I haven't reviewed this PR. I did build and test the samples on this branch, on an implementation with no GL interop running on an x86 CPU.
| cd build | ||
| if [[ "${{ matrix.os }}" == "ubuntu-20.04" ]]; then | ||
| sudo apt update | ||
| sudo apt install -y libtclap-dev libglm-dev libglew-dev libsfml-dev libstb-dev libidn11 libx11-dev libxrandr-dev libxi-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libudev-dev |
There was a problem hiding this comment.
I know Ubuntu isn't universal, but it might be helpful to put this in the readme. Or at least the ones that aren't there by default on a desktop install.
I had to install these to get the SDK to build:
sudo apt install libtclap-dev libstb-dev libglew-dev libsfml-dev libglm-devThere was a problem hiding this comment.
These packages are mentioned in the OpenCL-Guide in the Linux guide here. These are only required if one builds the samples and not otherwise.
There was a problem hiding this comment.
I'm guessing this is only needed if the package dependencies aren't satisfied via vcpkg?
Regardless, I agree it would be worth including this as an alternative in the README. Installing via the OS package manager will likely be smoother than vcpkg (getting it working on Ubuntu wasn't trivial) and this is the mechanism we're testing in CI.
There was a problem hiding this comment.
One can install them either way. It's user preference.
.gitlab/stream-ci.yaml
Outdated
| -D OPENCL_ICD_LOADER_BUILD_TESTING=ON | ||
| -D BUILD_DOCS=OFF | ||
| -D BUILD_EXAMPLES=OFF | ||
| -D BUILD_TESTS=ON |
There was a problem hiding this comment.
Should some of these be set in the CMakeLists.txt?
This line in particular I had to set to get anything to build (I suspect that is actually a bug in OpenCL-CLHPP CMake, but it wasn't immediately clear why -- I'll look again later).
Other variables are not essential, but setting them saves building unnecessary tests.
There was a problem hiding this comment.
Yes, I was thinking hard about making that also part of these PRs, but... scope creep. I really want to make the test option variables consistent. Currently only the ICD-Loader is able to selectively disable it's tests via OPENCL_ICD_LOADER_BUILD_TESTING and that's something the CLHPP repo should enable as well. One may want to test the SDK samples, but not build the few hundred header tests. I'll see to it shortly after the SDK and the base changes go through.
* WIP * Added error handling to context_properties * Initial Utility and SDK lib docs * Match definition to declaration * Fix constraints lifetime * Explicit narrowing conversion * Fix lifetime * Initial NBody sample * Reduce NBody particle count * NBody docs * Add GLM as a dependency * Don't draw after closing window * Fix InteropWindow namespace * Don't call CTOR explicitly * Simplify includes * Build SDK libs in correct place * Hook SDK deps to the correct targerts * Only install Util headers * Check for TCLAP alongside other deps * Only check for sample deps when building them * Add TCLAP to SDK props * Build SDK lib only with samples * Inherit common deps from libSDK * Modularize Stb detection for non-Vcpkg consumers * Revamp dependency use * Install layout overhaul * Fix CI YAML * Fix dynamic library dependence in install tree * Update readme * Don't test NBody using CTest * Move image Dockerfiles to OpenCL-SDK * Remove dead kernel code * README typo fixes. * Newline * Update submodules to point GitHub * Apply git-format * CI bump * Install deps. * apt update * Install stb * Acknolwedge Linux stb install layout * Fix build path * Fix vcpkg paths Co-authored-by: Ivan Siutsou <ivan@streamhpc.com>
Remove bogus full path from CMake invocation Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Multiline command syntax Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
Co-authored-by: Alastair Murray <alastair.murray@codeplay.com>
962c442 to
87e1d9d
Compare
This PR ships a larger batch of samples and the initial set of C/C++ utility libraries and SDK libraries. This PR includes:
Some notes on the shape of the SDK samples and some of the design choices: