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

Class Platform

include/CL/opencl.hpp:2646–3001  ·  view source on GitHub ↗

! \brief Class interface for cl_platform_id. * * \note Copies of these objects are inexpensive, since they don't 'own' * any underlying resources or data structures. * * \see cl_platform_id */

Source from the content-addressed store, hash-verified

2644 * \see cl_platform_id
2645 */
2646class Platform : public detail::Wrapper<cl_platform_id>
2647{
2648private:
2649 static std::once_flag default_initialized_;
2650 static Platform default_;
2651 static cl_int default_error_;
2652
2653 /*! \brief Create the default context.
2654 *
2655 * This sets @c default_ and @c default_error_. It does not throw
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 *
2698 * This sets @c default_. It does not throw
2699 * @c cl::Error.
2700 */
2701 static void makeDefaultProvided(const Platform &p) {
2702 default_ = p;
2703 }

Callers 3

makeDefaultMethod · 0.85
unitTestClearDefaultMethod · 0.85
getMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected