$darkmode
A high-performance general-purpose compute library
/home/abuild/rpmbuild/BUILD/arrayfire-full-v3.9.0/docs/pages/configuring_arrayfire_environment.md
Go to the documentation of this file.
1 Configuring ArrayFire Environment {#configuring_environment}
2 ===============================================================================
3 
4 This page lists environment and runtime configurations that will help enhance
5 your experience with ArrayFire.
6 
7 [TOC]
8 
9 Environment Variables{#environment_variables}
10 ===============================================================================
11 
12 The following are useful environment variable that can be used with ArrayFire.
13 
14 AF_PATH {#af_path}
15 -------------------------------------------------------------------------------
16 
17 This is the path with ArrayFire gets installed, ie. the includes and libs are
18 present in this directory. You can use this variable to add include paths and
19 libraries to your projects.
20 
21 AF_PRINT_ERRORS {#af_print_errors}
22 -------------------------------------------------------------------------------
23 
24 When AF_PRINT_ERRORS is set to 1, the exceptions thrown are more verbose and
25 detailed. This helps in locating the exact failure.
26 
27 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 AF_PRINT_ERRORS=1 ./myprogram
29 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 
31 AF_CUDA_DEFAULT_DEVICE {#af_cuda_default_device}
32 -------------------------------------------------------------------------------
33 
34 Use this variable to set the default CUDA device. Valid values for this
35 variable are the device identifiers shown when af::info is run.
36 
37 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 AF_CUDA_DEFAULT_DEVICE=1 ./myprogram_cuda
39 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40 
41 AF_ONEAPI_DEFAULT_DEVICE {#af_oneapi_default_device}
42 -------------------------------------------------------------------------------
43 
44 Use this variable to set the default oneAPI device. Valid values for this
45 variable are the device identifiers shown when af::info is run.
46 
47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48 AF_ONEAPI_DEFAULT_DEVICE=1 ./myprogram_oneapi
49 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 
51 Note: af::setDevice call in the source code will take precedence over this
52 variable.
53 
54 AF_OPENCL_DEFAULT_DEVICE {#af_opencl_default_device}
55 -------------------------------------------------------------------------------
56 
57 Use this variable to set the default OpenCL device. Valid values for this
58 variable are the device identifiers shown when af::info is run.
59 
60 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 AF_OPENCL_DEFAULT_DEVICE=1 ./myprogram_opencl
62 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63 
64 Note: af::setDevice call in the source code will take precedence over this
65 variable.
66 
67 AF_OPENCL_DEFAULT_DEVICE_TYPE {#af_opencl_default_device_type}
68 -------------------------------------------------------------------------------
69 
70 Use this variable to set the default OpenCL device type. Valid values for this
71 variable are: CPU, GPU, ACC (Accelerators).
72 
73 When set, the first device of the specified type is chosen as default device.
74 
75 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 AF_OPENCL_DEFAULT_DEVICE_TYPE=CPU ./myprogram_opencl
77 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78 
79 Note: `AF_OPENCL_DEFAULT_DEVICE` and af::setDevice takes precedence over this variable.
80 
81 AF_OPENCL_DEVICE_TYPE {#af_opencl_device_type}
82 -------------------------------------------------------------------------------
83 
84 Use this variable to only choose OpenCL devices of specified type. Valid values for this
85 variable are:
86 
87 - ALL: All OpenCL devices. (Default behavior).
88 - CPU: CPU devices only.
89 - GPU: GPU devices only.
90 - ACC: Accelerator devices only.
91 
92 When set, the remaining OpenCL device types are ignored by the OpenCL backend.
93 
94 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 AF_OPENCL_DEVICE_TYPE=CPU ./myprogram_opencl
96 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97 
98 AF_OPENCL_CPU_OFFLOAD {#af_opencl_cpu_offload}
99 -------------------------------------------------------------------------------
100 
101 When ArrayFire runs on devices with unified memory with the host (ie.
102 `CL_DEVICE_HOST_UNIFIED_MENORY` is true for the device) then certain functions
103 are offloaded to run on the CPU using mapped buffers.
104 
105 ArrayFire takes advantage of fast libraries such as MKL while spending no time
106 copying memory from device to host. The device memory is mapped to a host
107 pointer which can be used in the offloaded functions.
108 
109 This functionality can be disabled by using the environment variable
110 `AF_OPENCL_CPU_OFFLOAD=0`.
111 
112 The default bevaior of this has changed in version 3.4.
113 
114 Prior to v3.4, CPU Offload functionality was used only when the user set
115 `AF_OPENCL_CPU_OFFLOAD=1` and disabled otherwise.
116 
117 From v3.4 onwards, CPU Offload is enabled by default and is disabled only when
118 `AF_OPENCL_CPU_OFFLOAD=0` is set.
119 
120 AF_OPENCL_SHOW_BUILD_INFO {#af_opencl_show_build_info}
121 -------------------------------------------------------------------------------
122 
123 This variable is useful when debuggin OpenCL kernel compilation failures. When
124 this variable is set to 1, and an error occurs during a OpenCL kernel
125 compilation, then the log and kernel are printed to screen.
126 
127 AF_DISABLE_GRAPHICS {#af_disable_graphics}
128 -------------------------------------------------------------------------------
129 
130 Setting this variable to 1 will disable window creation when graphics
131 functions are being called. Disabling window creation will disable all other
132 graphics calls at runtime as well.
133 
134 This is a useful enviornment variable when running code on servers and systems
135 without displays. When graphics calls are run on such machines, they will
136 print warning about window creation failing. To suppress those calls, set this
137 variable.
138 
139 AF_SYNCHRONOUS_CALLS {#af_synchronous_calls}
140 -------------------------------------------------------------------------------
141 
142 When this environment variable is set to 1, ArrayFire will execute all
143 functions synchronously.
144 
145 AF_SHOW_LOAD_PATH {#af_show_load_path}
146 -------------------------------------------------------------------------------
147 
148 When using the Unified backend, if this variable is set to 1, it will show the
149 path where the ArrayFire backend libraries are loaded from.
150 
151 If the libraries are loaded from system paths, such as PATH or LD_LIBRARY_PATH
152 etc, then it will print "system path". If the libraries are loaded from other
153 paths, then those paths are shown in full.
154 
155 AF_MEM_DEBUG {#af_mem_debug}
156 -------------------------------------------------------------------------------
157 
158 When AF_MEM_DEBUG is set to 1 (or anything not equal to 0), the caching
159 mechanism in the memory manager is disabled. The device buffers are allocated
160 using native functions as needed and freed when going out of scope.
161 
162 When the environment variable is not set, it is treated to be zero.
163 
164 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165 AF_MEM_DEBUG=1 ./myprogram
166 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167 
168 AF_TRACE {#af_trace}
169 -------------------------------------------------------------------------------
170 
171 If ArrayFire was built with logging support, this enviornment variable will
172 enable tracing of various modules within ArrayFire. This is a comma separated
173 list of modules to trace. If enabled, ArrayFire will print relevant information
174 to stdout. Currently the following modules are supported:
175 
176 - all: All trace outputs
177 - jit: Logs kernel fetch & respective compile options and any errors.
178 - mem: Memory management allocation, free and garbage collection information
179 - platform: Device management information
180 - unified: Unified backend dynamic loading information
181 
182 Tracing displays the information that could be useful when debugging or
183 optimizing your application. Here is how you would use this variable:
184 
185  AF_TRACE=mem,unified ./myprogram
186 
187 This will print information about memory operations such as allocations,
188 deallocations, and garbage collection.
189 
190 All trace statements printed to the console have a suffix with the following
191 pattern.
192 
193 **[category][Seconds since Epoch][Thread Id][source file relative path] <Message>**
194 
195 AF_MAX_BUFFERS {#af_max_buffers}
196 -------------------------------------------------------------------------
197 
198 When AF_MAX_BUFFERS is set, this environment variable specifies the maximum
199 number of buffers allocated before garbage collection kicks in.
200 
201 Please note that the total number of buffers that can exist simultaneously can
202 be higher than this number. This variable tells the garbage collector that it
203 should free any available buffers immediately if the treshold is reached.
204 
205 When not set, the default value is 1000.
206 
207 AF_OPENCL_MAX_JIT_LEN {#af_opencl_max_jit_len}
208 -------------------------------------------------------------------------------
209 
210 When set, this environment variable specifies the maximum height of the OpenCL
211 JIT tree after which evaluation is forced.
212 
213 The default value, as of v3.4, is 50 on OSX, 100 everywhere else. This value was
214 20 for older versions.
215 
216 AF_CUDA_MAX_JIT_LEN {#af_cuda_max_jit_len}
217 -------------------------------------------------------------------------------
218 
219 When set, this environment variable specifies the maximum height of the CUDA JIT
220 tree after which evaluation is forced.
221 
222 The default value, as of v3.4, 100. This value was 20 for older versions.
223 
224 AF_CPU_MAX_JIT_LEN {#af_cpu_max_jit_len}
225 -------------------------------------------------------------------------------
226 
227 When set, this environment variable specifies the maximum length of the CPU JIT
228 tree after which evaluation is forced.
229 
230 The default value, as of v3.4, 100. This value was 20 for older versions.
231 
232 AF_BUILD_LIB_CUSTOM_PATH {#af_build_lib_custom_path}
233 -------------------------------------------------------------------------------
234 
235 When set, this environment variable specifies a custom path along which the
236 symbol manager will search for dynamic (shared library) backends to load. This
237 is useful for specialized build configurations that use the unified backend and
238 build shared libraries separately.
239 
240 By default, no additional path will be searched for an empty value.
241 
242 
243 AF_JIT_KERNEL_TRACE {#af_jit_kernel_trace}
244 -------------------------------------------------------------------------------
245 
246 When set, this environment variable has to be set to one of the following
247 three values:
248 
249 - stdout : generated kernels will be printed to standard output
250 - stderr : generated kernels will be printed to standard error stream
251 - absolute path to a folder on the disk where generated kernels will be stored
252 
253 CUDA backend kernels are stored in files with cu file extension.
254 
255 OpenCL backend kernels are stored in files with cl file extension.
256 
257 AF_JIT_KERNEL_CACHE_DIRECTORY {#af_jit_kernel_cache_directory}
258 -------------------------------------------------------------------------------
259 
260 This variable sets the path to the ArrayFire cache on the filesystem. If set
261 ArrayFire will write the kernels that are compiled at runtime to this directory.
262 If the path is not writeable, the default path is used.
263 
264 This path is different from AF_JIT_KERNEL_TRACE which stores strings. These
265 kernels will store binaries and the content will be dependent on the
266 backend and platforms used.
267 
268 The default path is determined in the following order:
269  Unix:
270  1. $HOME/.arrayfire
271  2. /tmp/arrayfire
272  Windows:
273  1. ArrayFire application Temp folder(Usually
274  C:\\Users\\<user_name>\\AppData\\Local\\Temp\\ArrayFire)