-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way for applications to use a single adapter #355
Comments
thanks @pbalcer . maybe we don't need anything else than UR_ADAPTERS_FORCE_LOAD ? Good thing about it UR_ADAPTERS_FORCE_LOAD is that users can select one time L0, and the next time CUDA, w/o needing to force a specific change in the code. Having a flag urInit might translate then into another env var in SYCL probably, to know which flag to pass there. if loader sees UR_ADAPTERS_FORCE_LOAD, then loader would just passthrough directly to the adapter selected, right? are there any disadvantages or limitations on using UR_ADAPTERS_FORCE_LOAD? |
Yes, if there's only one adapter specified (it supports a comma-separated list) in The only problem with this approach I can think of is that it requires the user to know the exact full path to the adapter (or just the exact library name if the adapter resides in a path that Maybe we should have a conf file/dir in |
thanks @pbalcer . Ah, so UR_ADAPTERS_FORCE_LOAD takes full path? I thought it only needed the name of the adapter. Then maybe we need another env var? something like UR_ADAPTER_LIST=<level_zero>,,, which takes a comma separated list of adapters to use. If only one passed, then passthrough in the loader is used. We could either use the same format as ONEAPI_DEVICE_SELECTOR, https://intel.github.io/llvm-docs/EnvironmentVariables.html, or even better, just read ONEAPI_DEVICE_SELECTOR in the UR loader and if only one backend selected, then pass-through. |
Yes, |
QMCPack uses MPI + SYCL + OpenMP. All three SW components can and do offload tasks to the available devices, possibly via different backends. All three could/will become clients of UR in the near future. The UR_ADAPTERS_FORCE_LOAD option works, even in this situation, because it restricts all clients of UR equitably (all get passthrough or none do). OpenMP requires only one adapter (because of a requirement for homogeneity of devices, allegedly) -- it will wish always to call |
The current UR loader, to support multiple adapters, has an indirection layer that creates and maintains wrappers around UR entities (or function class types, i.e.,
platform
,device
and so on) that store a pointer to adapter functions. If there's only one adapter, this layer is unused, and the loader calls the adapter functions directly.This indirection adds an extraneous overhead for applications that use only one adapter but have more available in the system. This issue is to devise a way to allow applications to load and use only the desired adapter implementation, thus avoiding the overhead.
Possible solutions:
UR_ADAPTERS_FORCE_LOAD
environmental variable can be set with a desired adapter, forcing the loader to use it. This is already possible.platform_flags
tourInit
, with a way of selecting a single adapter.UR_PLATFORM_USE_FIRST
. But this might be hard to use since the order of adapters is unspecified.UR_PLATFORM_L0
,UR_PLATFORM_CUDA
,UR_PLATFORM_HIP
, and then this could be used like this:urInit(0, UR_PLATFORM_L0 | UR_PLATFORM_CUDA);
. This would only work with predefined platforms.urInit
, for example:urInit(0, [](struct platform_descriptor *d) -> bool { return strcmp(d->name, "ur_adapter_level_zero") == 0; })
. This might be clunky to use from C, but I think is the most universal.urPlatformUnload
on the ones it doesn't intend to use orurPlatformUseOnlyThis
(can't think of a name right now :-)) on the one it does. This fits into the existing API, but might be error-prone and tricky to implement safely.The text was updated successfully, but these errors were encountered: