================ @@ -0,0 +1,128 @@ +//===- LevelZeroArch.cpp - list installed Level Zero devices ---*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements a tool for detecting Level Zero devices installed in the +// system +// +//===----------------------------------------------------------------------===// + +#ifndef HAVE_LEVEL_ZERO_HEADERS + +int printGPUsByLevelZero() { return 0; } + +#else + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/DynamicLibrary.h" +#include "llvm/Support/Error.h" +#include <cstdio> +#include <level_zero/ze_api.h> + +using namespace llvm; +extern cl::opt<bool> Verbose; + +#define DEFINE_WRAPPER(NAME) \ + using NAME##_ty = decltype(NAME); \ + void *NAME##Ptr = nullptr; \ + template <class... Ts> ze_result_t NAME##_wrap(Ts... args) { \ + if (!NAME##Ptr) { \ + return ZE_RESULT_ERROR_UNKNOWN; \ + } \ + return reinterpret_cast<NAME##_ty *>(NAME##Ptr)(args...); \ + }; + +DEFINE_WRAPPER(zeInitDrivers) +DEFINE_WRAPPER(zeDeviceGet) +DEFINE_WRAPPER(zeDeviceGetProperties) + +static bool loadLevelZero() { + const char *L0Library = "libze_loader.so"; ---------------- sarnex wrote:
could make this `constexpr const char *` like nvptx does https://github.com/llvm/llvm-project/pull/160570 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
