computecpp-sdk icon indicating copy to clipboard operation
computecpp-sdk copied to clipboard

Disable reruns of FindComputeCpp.cmake

Open MathiasMagnus opened this issue 7 years ago • 2 comments

Every configuration run prints out the same diagnostic messages which are fairly annoying, but at least not necessary.

1> -- platform - your system can support ComputeCpp
1> -- Device compiler does not meet certain STL version requirements. Disabling version checks and hoping for the best.
1> -- compute++ flags - -O2;-mllvm;-inline-threshold=1000;-sycl;-intelspirmetadata;-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH;-sycl-target;spir64

No other FindPackage prints out their finding on every run, but only on the first. (FindOpenCL.cmake for eg., but any other would do.) These messages, and generally all other tests should be guarded against multiple executions.

MathiasMagnus avatar Nov 15 '18 12:11 MathiasMagnus

Offhand, do you know how they achieve this - I'm guessing they check ComputeCpp_FOUND? But then, how do you invalidate that if the user updates (for example) ComputeCpp_DIR? I confess I don't really know how best to achieve this...

DuncanMcBain avatar Nov 15 '18 21:11 DuncanMcBain

I have never really thought about it, what the actual mechanism is. Peeking at the aforementioned FindOpenCL.cmake (link), a few useful modules are at play I did not know of, such as CMakePushCheckState, but most importantly a some of the checks still run, but silently.

First, the header cl.h is looked for. If found, then it looks for a define inside to find out the version. These tests run unconditionally, at least it seems very much like it. The result of CHECK_SYMBOL_EXISTS must be cached somewhere, because subsequent configurations are much faster.

After the library is looked for and finally, find_package_handle_standard_args is invoked and if everything was found AND the target OpenCL::OpenCL has not yet been created, it is defined.

Subsequent invocations do not look for headers, because the output variable is populated. Version checks may be omitted, because all the output variables exist either as Not-Found or some value. Library is not looked for again, because output variable holds value, and find_package_handle_standard_args will also not run, just like the redefinition of the targets.

All in all, if the hand-rolled, noisy checks and the diagnostic messages would check for the value of ComputeCpp_FOUND and not run if it's set to TRUE, and safeguarding other non-shortcircuitable checks if the library has already been found, that would be great.

MathiasMagnus avatar Nov 15 '18 22:11 MathiasMagnus