mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 21:29:24 -08:00
This PR adds a new template into `dlwrap` namespace that can be used to check if a symbol was correctly loaded. It adds and easy way to see if version of shared object in a system has required capability. We could use it to improve prefetch in CUDA backend as noted [here](https://github.com/llvm/llvm-project/blob/main/offload/plugins-nextgen/cuda/src/rtl.cpp#L912) without breaking compatibility with older platforms using CUDA older than 13. In the case of prefetch, the new `dlwrap` API could be used like: ```cpp bool BatchedPrefetchAvailable = dlwrap::loaded<cuMemPrefetchBatchAsync>(); if (BatchedPrefetchAvailable) cuMemPrefetchAsync(....) else // Current implementation ``` Small note, to implement the prefetch we will also have to make loading of the symbols optional inside plugins too. This would require to change it [here](https://github.com/llvm/llvm-project/blob/main/offload/plugins-nextgen/cuda/dynamic_cuda/cuda.cpp#L176), but I think that the change can be a part of a PR that implements prefetch.
29 lines
1.2 KiB
C
29 lines
1.2 KiB
C
//===--- Level Zero Target RTL Implementation -----------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Level Zero compatibility layer enabling us to compile using new APIs.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0COMPAT_H
|
|
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0COMPAT_H
|
|
|
|
#include "APIHelpers.h"
|
|
|
|
#include <level_zero/ze_api.h>
|
|
|
|
API_HELPER_OPTIONAL(ze_result_t, zeCommandListAppendLaunchKernelWithArguments,
|
|
ze_command_list_handle_t hCommandList,
|
|
ze_kernel_handle_t hKernel,
|
|
const ze_group_count_t groupCounts,
|
|
const ze_group_size_t groupSizes, void **pArguments,
|
|
const void *pNext, ze_event_handle_t hSignalEvent,
|
|
uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents);
|
|
|
|
#endif // OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_L0COMPAT_H
|