Skip to content

Commit b511bf8

Browse files
authored
Merge pull request #9 from kpouget/remoting
Cache values and reduce the logging
2 parents 4921388 + 67d00e7 commit b511bf8

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

ggml/src/ggml-remotingfrontend/ggml-backend-buffer-type.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
static ggml_backend_buffer_t
77
ggml_backend_remoting_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft, size_t size) {
8-
IMPLEMENTED;
8+
IMPLEMENTED_ONCE;
99
struct virtgpu *gpu = BUFT_TO_GPU(buft);
1010

1111
struct ggml_backend_remoting_buffer_context *context = (struct ggml_backend_remoting_buffer_context *) malloc(sizeof(*context));
@@ -29,9 +29,6 @@ ggml_backend_remoting_buffer_type_alloc_buffer(ggml_backend_buffer_type_t buft,
2929
context->is_host_buffer = false;
3030

3131
ggml_backend_buffer_t buffer = ggml_backend_buffer_init(buft, ggml_backend_remoting_buffer_interface, (void *) context, size);
32-
INFO("##");
33-
INFO("## %s(%llx) --> %p <---------------", __func__, size, buffer);
34-
INFO("##\n");
3532

3633
return buffer;
3734
}
@@ -47,19 +44,29 @@ ggml_backend_remoting_buffer_type_get_name(ggml_backend_buffer_type_t buft) {
4744

4845
static size_t
4946
ggml_backend_remoting_buffer_type_get_alignment(ggml_backend_buffer_type_t buft) {
50-
IMPLEMENTED;
51-
47+
IMPLEMENTED_ONCE;
5248
struct virtgpu *gpu = BUFT_TO_GPU(buft);
5349

54-
return apir_buffer_type_get_alignment(gpu, buft);
50+
static size_t align = 0;
51+
52+
if (align == 0) {
53+
align = apir_buffer_type_get_alignment(gpu, buft);
54+
}
55+
56+
return align;
5557
}
5658

5759
static size_t
5860
ggml_backend_remoting_buffer_type_get_max_size(ggml_backend_buffer_type_t buft) {
59-
IMPLEMENTED;
61+
IMPLEMENTED_ONCE;
6062
struct virtgpu *gpu = BUFT_TO_GPU(buft);
6163

62-
return apir_buffer_type_get_max_size(gpu, buft);
64+
static size_t max_size = 0;
65+
if (max_size == 0) {
66+
max_size = apir_buffer_type_get_max_size(gpu, buft);
67+
}
68+
69+
return max_size;
6370
}
6471

6572
static bool

ggml/src/ggml-remotingfrontend/ggml-backend-device.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@ ggml_backend_remoting_device_get_description(ggml_backend_dev_t dev) {
2020

2121
static enum ggml_backend_dev_type
2222
ggml_backend_remoting_device_get_type(ggml_backend_dev_t dev) {
23-
IMPLEMENTED;
24-
23+
IMPLEMENTED_ONCE;
2524
struct virtgpu *gpu = DEV_TO_GPU(dev);
2625

27-
return (enum ggml_backend_dev_type) apir_device_get_type(gpu);
26+
static enum ggml_backend_dev_type type;
27+
static bool has_type = false;
28+
if (!has_type) {
29+
has_type = true;
30+
type = (enum ggml_backend_dev_type) apir_device_get_type(gpu);
31+
}
32+
33+
return type;
2834
}
2935

3036
static void

ggml/src/ggml-remotingfrontend/venus_cs_ggml-rpc-front.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ serialize_tensor(const ggml_tensor * tensor) {
1818
ggml_backend_buffer_t buffer = tensor->buffer;
1919

2020
result.buffer = BUFFER_TO_HOST_HANDLE(buffer);
21-
if (result.buffer < 0x600000000000 || result.buffer > 0x700000000000) {
22-
INFO("pass buffer handle %p", result.buffer);
23-
BREAKPOINT;
24-
}
2521
} else {
2622
result.buffer = 0;
2723
}

0 commit comments

Comments
 (0)