MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / create_virtgpu

Function create_virtgpu

external/ggml/src/ggml-virtgpu/virtgpu.cpp:177–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177virtgpu * create_virtgpu() {
178 virtgpu * gpu = new virtgpu();
179
180 gpu->use_apir_capset = getenv("GGML_REMOTING_USE_APIR_CAPSET") != nullptr;
181 util_sparse_array_init(&gpu->shmem_array, sizeof(virtgpu_shmem), 1024);
182
183 // Initialize mutex to protect shared data_shmem buffer
184 if (mtx_init(&gpu->data_shmem_mutex, mtx_plain) != thrd_success) {
185 delete gpu;
186 GGML_ABORT(GGML_VIRTGPU "%s: failed to initialize data_shmem mutex", __func__);
187 return NULL;
188 }
189
190 if (virtgpu_open(gpu) != APIR_SUCCESS) {
191 GGML_LOG_ERROR(GGML_VIRTGPU "%s: failed to open the virtgpu device\n", __func__);
192 return NULL;
193 }
194
195 if (virtgpu_init_capset(gpu) != APIR_SUCCESS) {
196 if (gpu->use_apir_capset) {
197 GGML_ABORT(GGML_VIRTGPU
198 "%s: failed to initialize the virtgpu APIR capset. Make sure that the virglrenderer library "
199 "supports it.",
200 __func__);
201 } else {
202 GGML_ABORT(GGML_VIRTGPU "%s: failed to initialize the virtgpu Venus capset", __func__);
203 }
204 return NULL;
205 }
206
207 if (virtgpu_init_context(gpu) != APIR_SUCCESS) {
208 GGML_ABORT(GGML_VIRTGPU "%s: failed to initialize the GPU context", __func__);
209 return NULL;
210 }
211
212 if (virtgpu_shmem_create(gpu, SHMEM_REPLY_SIZE, &gpu->reply_shmem)) {
213 GGML_ABORT(GGML_VIRTGPU "%s: failed to create the shared reply memory pages", __func__);
214 return NULL;
215 }
216
217 if (virtgpu_shmem_create(gpu, SHMEM_DATA_SIZE, &gpu->data_shmem)) {
218 GGML_ABORT(GGML_VIRTGPU "%s: failed to create the shared data memory pages", __func__);
219 return NULL;
220 }
221
222 if (virtgpu_handshake(gpu)) {
223 GGML_ABORT(GGML_VIRTGPU "%s: failed to handshake with the virglrenderer library", __func__);
224 return NULL;
225 }
226
227 if (virtgpu_load_library(gpu) != APIR_LOAD_LIBRARY_SUCCESS) {
228 GGML_ABORT(GGML_VIRTGPU "%s: failed to load the backend library", __func__);
229 return NULL;
230 }
231
232 return gpu;
233}
234

Callers 1

apir_initializeFunction · 0.85

Calls 7

util_sparse_array_initFunction · 0.85
virtgpu_openFunction · 0.85
virtgpu_init_capsetFunction · 0.85
virtgpu_init_contextFunction · 0.85
virtgpu_shmem_createFunction · 0.85
virtgpu_handshakeFunction · 0.85
virtgpu_load_libraryFunction · 0.85

Tested by

no test coverage detected