MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / makeDefault

Method makeDefault

include/CL/opencl.hpp:2658–2694  ·  view source on GitHub ↗

! \brief Create the default context. * * This sets @c default_ and @c default_error_. It does not throw * @c cl::Error. */

Source from the content-addressed store, hash-verified

2656 * @c cl::Error.
2657 */
2658 static void makeDefault() {
2659 /* Throwing an exception from a call_once invocation does not do
2660 * what we wish, so we catch it and save the error.
2661 */
2662#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2663 try
2664#endif
2665 {
2666 // If default wasn't passed ,generate one
2667 // Otherwise set it
2668 cl_uint n = 0;
2669
2670 cl_int err = ::clGetPlatformIDs(0, nullptr, &n);
2671 if (err != CL_SUCCESS) {
2672 default_error_ = err;
2673 return;
2674 }
2675 if (n == 0) {
2676 default_error_ = CL_INVALID_PLATFORM;
2677 return;
2678 }
2679
2680 vector<cl_platform_id> ids(n);
2681 err = ::clGetPlatformIDs(n, ids.data(), nullptr);
2682 if (err != CL_SUCCESS) {
2683 default_error_ = err;
2684 return;
2685 }
2686
2687 default_ = Platform(ids[0]);
2688 }
2689#if defined(CL_HPP_ENABLE_EXCEPTIONS)
2690 catch (cl::Error &e) {
2691 default_error_ = e.err();
2692 }
2693#endif
2694 }
2695
2696 /*! \brief Create the default platform from a provided platform.
2697 *

Callers

nothing calls this directly

Calls 3

clGetPlatformIDsFunction · 0.85
PlatformClass · 0.85
dataMethod · 0.45

Tested by

no test coverage detected