MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / create_virtgpu

Function create_virtgpu

ggml/src/ggml-virtgpu/virtgpu.cpp:176–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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