@@ -71,28 +71,136 @@ GPUARRAY_PUBLIC int gpu_get_device_count(const char* name,
7171 unsigned int platform ,
7272 unsigned int * devcount );
7373
74+
75+ /**
76+ * Opaque structure that holds properties for the context.
77+ */
7478typedef struct _gpucontext_props gpucontext_props ;
7579
80+ /**
81+ * Allocate and initialized an instance of gpucontext_props.
82+ *
83+ * Initialization is done with default values.
84+ *
85+ * \param res pointer to storage space for the created object
86+ *
87+ * \returns GA_NO_ERROR or an error code if an error occurred.
88+ */
7689GPUARRAY_PUBLIC int gpucontext_props_new (gpucontext_props * * res );
7790
91+ /**
92+ * Set the device number for a CUDA device.
93+ *
94+ * \param p properties object
95+ * \param devno device number
96+ *
97+ * \returns GA_NO_ERROR or an error code if an error occurred.
98+ */
7899GPUARRAY_PUBLIC int gpucontext_props_cuda_dev (gpucontext_props * p , int devno );
79100
101+
102+ /**
103+ * Set the platform and device for OpenCL.
104+ *
105+ * \param p properties object
106+ * \param platno platform number
107+ * \param devno device number
108+ *
109+ * \returns GA_NO_ERROR or an error code if an error occurred.
110+ */
80111GPUARRAY_PUBLIC int gpucontext_props_opencl_dev (gpucontext_props * p ,
81112 int platno , int devno );
82113
114+ /**
115+ * Set the scheduling mode for the device.
116+ *
117+ * \param p properties object
118+ * \param sched scheduling mode. One of \ref sched_modes "these".
119+ *
120+ * \returns GA_NO_ERROR or an error code if an error occurred.
121+ */
122+ GPUARRAY_PUBLIC int gpucontext_props_sched (gpucontext_props * p , int sched );
123+
124+ /** \defgroup sched_modes
125+ * @{
126+ */
127+
128+ /**
129+ * Automatic scheduling, decide what to do depending on the workload,
130+ * number of cores in the computer and other relevant factors. (default)
131+ */
83132#define GA_CTX_SCHED_AUTO 0
133+
134+ /**
135+ * Single-work scheduling. Optimize for speed in a single process,
136+ * with a single thread. This is the fastest mode, but it may keep
137+ * the CPU busy more than necessary.
138+ */
84139#define GA_CTX_SCHED_SINGLE 1
140+
141+ /**
142+ * Multi-work scheduling. Try to not keep the CPU busy more than
143+ * necessary and let other threads a chance at some CPU time. This
144+ * may increase the latency when waiting for GPU operations.
145+ */
85146#define GA_CTX_SCHED_MULTI 2
86- GPUARRAY_PUBLIC int gpucontext_props_sched (gpucontext_props * p , int sched );
87147
148+ /** @}*/
149+
150+ /**
151+ * Set single-stream mode.
152+ *
153+ * All operations on the device will be serialized on a single stream.
154+ * This will also disable most of the interlocking normally done
155+ * between multiple streams to keep everything in order.
156+ *
157+ * This mode can be faster if you don't have a lot of device-level
158+ * parallelism in your workload.
159+ *
160+ * \param p properties object
161+ *
162+ * \returns GA_NO_ERROR or an error code if an error occurred.
163+ */
88164GPUARRAY_PUBLIC int gpucontext_props_set_single_stream (gpucontext_props * p );
89165
166+ /**
167+ * Set the path for the kernel cache.
168+ *
169+ * The cache can be shared with other running instances, even on
170+ * shared drives.
171+ *
172+ * \param p properties object
173+ *
174+ * \returns GA_NO_ERROR or an error code if an error occurred.
175+ */
90176GPUARRAY_PUBLIC int gpucontext_props_kernel_cache (gpucontext_props * p ,
91177 const char * path );
92178
179+ /**
180+ * Configure the allocation cache.
181+ *
182+ * The maximum size is also a limit on the total amount of memory
183+ * allocated on the device.
184+ *
185+ * \param p properties object
186+ * \param initial initial size of the cache
187+ * \param max maximum size of the cache
188+ *
189+ * \returns GA_NO_ERROR or an error code if an error occurred.
190+ */
93191GPUARRAY_PUBLIC int gpucontext_props_alloc_cache (gpucontext_props * p ,
94192 size_t initial , size_t max );
95193
194+ /**
195+ * Free a properties object.
196+ *
197+ * This should not be called on a properties object that has been
198+ * passed to gpucontext_init().
199+ *
200+ * \param p properties object
201+ *
202+ * \returns GA_NO_ERROR or an error code if an error occurred.
203+ */
96204GPUARRAY_PUBLIC void gpucontext_props_del (gpucontext_props * p );
97205
98206/**
0 commit comments