KhronosGroup / OpenCL-SDK

OpenCL SDK
Apache License 2.0
577 stars 120 forks source link

Samples and Utility libraries #37

Closed MathiasMagnus closed 2 years ago

MathiasMagnus commented 2 years ago

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:

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

MathiasMagnus commented 2 years ago

@bashbaug I think I know where your woes are coming from (and both are totally legit).

  1. Not finding the library happens only with multi-config generators. Building using the default Unix Makefiles or Ninja works. Working on a fix.
  2. The headers is a sticky subject. (Semi-extensive exploration of the phase space is here, which I intend on merging into either the OpenCL-Guide or the SDK.) The 'current working directory' (henceforth cwd)-relative solution is simple, but is fairly brittle. Copying the kernels into the build tree is problematic because

    • One may copy at configuration time using file(COPY ...) or configure_file() but then one needs to reconfigure to update the files on disk. (It's annoying to develop samples that way.)
    • One may set it as a post-build step, but then it will only trigger when one modifies the host code. (This is annoying too.)
    • One may promote it to a build step, in which case utility targets like saxpy-kernel and nbody-kernel-shader start mildly polluting the list of available targets. Samples run fine from the install tree, because install commands can properly track the timestamps of both the executables and the kernel files.

Symlinking the kernels would be awesome, as it follows updates to code in the source tree, but that has many problems too:

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.

MathiasMagnus commented 2 years ago

All samples now execute correctly from the build tree as well as the install tree in both single and multi-config generators.