Halide
DeviceInterface.h
Go to the documentation of this file.
1 #ifndef HALIDE_DEVICE_INTERFACE_H
2 #define HALIDE_DEVICE_INTERFACE_H
3 
4 /** \file
5  * Methods for managing device allocations when jitting
6  */
7 
8 #include "Expr.h"
9 #include "Target.h"
10 
11 namespace Halide {
12 
13 /** Gets the appropriate halide_device_interface_t * for a
14  * DeviceAPI. If error_site is non-null, e.g. the name of the routine
15  * calling get_device_interface_for_device_api, a user_error is
16  * reported if the requested device API is not enabled in or supported
17  * by the target, Halide has been compiled without this device API, or
18  * the device API is None or Host or a bad value. The error_site
19  * argument is printed in the error message. If error_site is null,
20  * this routine returns nullptr instead of calling user_error. */
22  const Target &t = get_jit_target_from_environment(),
23  const char *error_site = nullptr);
24 
25 /** Get the specific DeviceAPI that Halide would select when presented
26  * with DeviceAPI::Default_GPU for a given target. If no suitable api
27  * is enabled in the target, returns DeviceAPI::Host. */
29 
30 /** This attempts to sniff whether a given Target (and its implied DeviceAPI) is usable on
31  * the current host. If it appears to be usable, return true; if not, return false.
32  * Note that a return value of true does *not* guarantee that future usage of
33  * that device will succeed; it is intended mainly as a simple diagnostic
34  * to allow early-exit when a desired device is definitely not usable.
35  * Also note that this call is *NOT* threadsafe, as it temporarily redirect various
36  * global error-handling hooks in Halide. */
37 bool host_supports_target_device(const Target &t);
38 
39 namespace Internal {
40 /** Get an Expr which evaluates to the device interface for the given device api at runtime. */
41 Expr make_device_interface_call(DeviceAPI device_api, MemoryType memory_type = MemoryType::Auto);
42 } // namespace Internal
43 
44 } // namespace Halide
45 
46 #endif
Halide::get_default_device_api_for_target
DeviceAPI get_default_device_api_for_target(const Target &t)
Get the specific DeviceAPI that Halide would select when presented with DeviceAPI::Default_GPU for a ...
Halide::host_supports_target_device
bool host_supports_target_device(const Target &t)
This attempts to sniff whether a given Target (and its implied DeviceAPI) is usable on the current ho...
Target.h
Halide::get_device_interface_for_device_api
const halide_device_interface_t * get_device_interface_for_device_api(DeviceAPI d, const Target &t=get_jit_target_from_environment(), const char *error_site=nullptr)
Gets the appropriate halide_device_interface_t * for a DeviceAPI.
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::make_device_interface_call
Expr make_device_interface_call(DeviceAPI device_api, MemoryType memory_type=MemoryType::Auto)
Get an Expr which evaluates to the device interface for the given device api at runtime.
Expr.h
Halide::get_jit_target_from_environment
Target get_jit_target_from_environment()
Return the target that Halide will use for jit-compilation.
Halide::MemoryType::Auto
@ Auto
Let Halide select a storage type automatically.
halide_device_interface_t
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
Definition: HalideRuntime.h:770
Halide::MemoryType
MemoryType
An enum describing different address spaces to be used with Func::store_in.
Definition: Expr.h:347
Halide::DeviceAPI
DeviceAPI
An enum describing a type of device API.
Definition: DeviceAPI.h:15