11/*
22 *
3- * Copyright (C) 2020-2021 Intel Corporation
3+ * Copyright (C) 2020-2023 Intel Corporation
44 *
55 * SPDX-License-Identifier: MIT
66 *
77 */
8- #include < stdlib.h>
9- #include < memory>
108#include < iostream>
9+ #include < memory>
10+ #include < stdlib.h>
1111#include < vector>
1212
1313#include " ur_api.h"
1414
1515// ////////////////////////////////////////////////////////////////////////
16- int main (int argc, char *argv[])
17- {
16+ int main (int argc, char *argv[]) {
1817 ur_result_t status;
1918
2019 ur_platform_handle_t platform = nullptr ;
2120 ur_device_handle_t pDevice = nullptr ;
2221
2322 // Initialize the platform
2423 status = urInit (0 , 0 );
25- if (status != UR_RESULT_SUCCESS)
26- {
24+ if (status != UR_RESULT_SUCCESS) {
2725 std::cout << " urInit failed with return code: " << status << std::endl;
2826 return 1 ;
2927 }
@@ -33,65 +31,68 @@ int main(int argc, char *argv[])
3331 std::vector<ur_platform_handle_t > platforms;
3432
3533 status = urPlatformGet (1 , nullptr , &platformCount);
36- if (status != UR_RESULT_SUCCESS)
37- {
38- std::cout << " urPlatformGet failed with return code: " << status << std::endl;
34+ if (status != UR_RESULT_SUCCESS) {
35+ std::cout << " urPlatformGet failed with return code: " << status
36+ << std::endl;
3937 goto out;
4038 }
4139
4240 platforms.resize (platformCount);
4341 status = urPlatformGet (platformCount, platforms.data (), nullptr );
44- if (status != UR_RESULT_SUCCESS)
45- {
46- std::cout << " urPlatformGet failed with return code: " << status << std::endl;
42+ if (status != UR_RESULT_SUCCESS) {
43+ std::cout << " urPlatformGet failed with return code: " << status
44+ << std::endl;
4745 goto out;
4846 }
4947
50- for (auto p : platforms)
51- {
48+ for (auto p : platforms) {
5249 ur_api_version_t api_version = {};
5350 status = urPlatformGetApiVersion (platform, &api_version);
54- if (status != UR_RESULT_SUCCESS)
55- {
56- std::cout << " urPlatformGetApiVersion failed with return code: " << status << std::endl;
51+ if (status != UR_RESULT_SUCCESS) {
52+ std::cout << " urPlatformGetApiVersion failed with return code: "
53+ << status << std::endl;
5754 goto out;
5855 }
59- std::cout << " API version: " << UR_MAJOR_VERSION (api_version) << " ." << UR_MINOR_VERSION (api_version) << std::endl;
56+ std::cout << " API version: " << UR_MAJOR_VERSION (api_version) << " ."
57+ << UR_MINOR_VERSION (api_version) << std::endl;
6058
6159 uint32_t deviceCount = 0 ;
6260 status = urDeviceGet (p, UR_DEVICE_TYPE_GPU, 0 , nullptr , &deviceCount);
63- if (status != UR_RESULT_SUCCESS)
64- {
65- std::cout << " urDeviceGet failed with return code: " << status << std::endl;
61+ if (status != UR_RESULT_SUCCESS) {
62+ std::cout << " urDeviceGet failed with return code: " << status
63+ << std::endl;
6664 goto out;
6765 }
6866
6967 std::vector<ur_device_handle_t > devices (deviceCount);
70- status = urDeviceGet (p, UR_DEVICE_TYPE_GPU, deviceCount, devices.data (), nullptr );
71- if (status != UR_RESULT_SUCCESS)
72- {
73- std::cout << " urDeviceGet failed with return code: " << status << std::endl;
68+ status = urDeviceGet (p, UR_DEVICE_TYPE_GPU, deviceCount, devices.data (),
69+ nullptr );
70+ if (status != UR_RESULT_SUCCESS) {
71+ std::cout << " urDeviceGet failed with return code: " << status
72+ << std::endl;
7473 goto out;
7574 }
76- for (auto d : devices)
77- {
75+ for (auto d : devices) {
7876 ur_device_type_t device_type;
79- status = urDeviceGetInfo (d, UR_DEVICE_INFO_TYPE, sizeof (ur_device_type_t ), static_cast <void *>(&device_type), nullptr );
80- if (status != UR_RESULT_SUCCESS)
81- {
82- std::cout << " urDeviceGetInfo failed with return code: " << status << std::endl;
77+ status = urDeviceGetInfo (
78+ d, UR_DEVICE_INFO_TYPE, sizeof (ur_device_type_t ),
79+ static_cast <void *>(&device_type), nullptr );
80+ if (status != UR_RESULT_SUCCESS) {
81+ std::cout << " urDeviceGetInfo failed with return code: "
82+ << status << std::endl;
8383 goto out;
8484 }
8585 static const size_t DEVICE_NAME_MAX_LEN = 1024 ;
8686 char device_name[DEVICE_NAME_MAX_LEN] = {0 };
87- status = urDeviceGetInfo (d, UR_DEVICE_INFO_NAME, DEVICE_NAME_MAX_LEN - 1 , static_cast <void *>(&device_name), nullptr );
88- if (status != UR_RESULT_SUCCESS)
89- {
90- std::cout << " urDeviceGetInfo failed with return code: " << status << std::endl;
87+ status =
88+ urDeviceGetInfo (d, UR_DEVICE_INFO_NAME, DEVICE_NAME_MAX_LEN - 1 ,
89+ static_cast <void *>(&device_name), nullptr );
90+ if (status != UR_RESULT_SUCCESS) {
91+ std::cout << " urDeviceGetInfo failed with return code: "
92+ << status << std::endl;
9193 goto out;
9294 }
93- if (device_type == UR_DEVICE_TYPE_GPU)
94- {
95+ if (device_type == UR_DEVICE_TYPE_GPU) {
9596 std::cout << " Found a " << device_name << " gpu.\n " ;
9697 }
9798 }
0 commit comments