@@ -1119,17 +1119,17 @@ void ggml_metal_buffer_memset_tensor(ggml_metal_buffer_t buf, struct ggml_tensor
11191119
11201120 @autoreleasepool {
11211121 // dst
1122- struct ggml_metal_buffer_id buf_dst = ggml_metal_buffer_get_id (buf, tensor);
1123- buf_dst .offs += offset;
1122+ struct ggml_metal_buffer_id bid_dst = ggml_metal_buffer_get_id (buf, tensor);
1123+ bid_dst .offs += offset;
11241124
11251125 id <MTLCommandQueue > queue = buf->queue ;
11261126 id <MTLCommandBuffer > cmd_buf = [queue commandBufferWithUnretainedReferences ];
11271127
11281128 {
11291129 id <MTLBlitCommandEncoder > encoder = [cmd_buf blitCommandEncoder ];
11301130
1131- [encoder fillBuffer: buf_dst .metal
1132- range: NSMakeRange (buf_dst .offs, buf_dst .offs + size)
1131+ [encoder fillBuffer: bid_dst .metal
1132+ range: NSMakeRange (bid_dst .offs, bid_dst .offs + size)
11331133 value: value];
11341134
11351135 [encoder endEncoding ];
@@ -1155,8 +1155,8 @@ void ggml_metal_buffer_set_tensor(ggml_metal_buffer_t buf, struct ggml_tensor *
11551155 deallocator: nil ];
11561156
11571157 // dst
1158- struct ggml_metal_buffer_id buf_dst = ggml_metal_buffer_get_id (buf, tensor);
1159- buf_dst .offs += offset;
1158+ struct ggml_metal_buffer_id bid_dst = ggml_metal_buffer_get_id (buf, tensor);
1159+ bid_dst .offs += offset;
11601160
11611161 // note: for experimentation purposes, here we use a semaphore to wait for the copy to complete
11621162 // this is alternative to waitUntilCompleted, which should be faster, but don't seem to make much difference
@@ -1170,8 +1170,8 @@ void ggml_metal_buffer_set_tensor(ggml_metal_buffer_t buf, struct ggml_tensor *
11701170
11711171 [encoder copyFromBuffer: buf_src
11721172 sourceOffset: 0
1173- toBuffer: buf_dst .metal
1174- destinationOffset: buf_dst .offs
1173+ toBuffer: bid_dst .metal
1174+ destinationOffset: bid_dst .offs
11751175 size: size];
11761176
11771177 [encoder endEncoding ];
@@ -1187,6 +1187,8 @@ void ggml_metal_buffer_set_tensor(ggml_metal_buffer_t buf, struct ggml_tensor *
11871187 [cmd_buf commit ];
11881188
11891189 dispatch_semaphore_wait (completion_semaphore, DISPATCH_TIME_FOREVER);
1190+ dispatch_release (completion_semaphore);
1191+
11901192 // [cmd_buf waitUntilCompleted];
11911193 }
11921194}
@@ -1199,8 +1201,8 @@ void ggml_metal_buffer_get_tensor(ggml_metal_buffer_t buf, const struct ggml_ten
11991201
12001202 @autoreleasepool {
12011203 // src
1202- struct ggml_metal_buffer_id buf_src = ggml_metal_buffer_get_id (buf, tensor);
1203- buf_src .offs += offset;
1204+ struct ggml_metal_buffer_id bid_src = ggml_metal_buffer_get_id (buf, tensor);
1205+ bid_src .offs += offset;
12041206
12051207 // dst
12061208 id <MTLBuffer > buf_dst = [buf->device newBufferWithBytesNoCopy: data
@@ -1214,8 +1216,8 @@ void ggml_metal_buffer_get_tensor(ggml_metal_buffer_t buf, const struct ggml_ten
12141216 {
12151217 id <MTLBlitCommandEncoder > encoder = [cmd_buf blitCommandEncoder ];
12161218
1217- [encoder copyFromBuffer: buf_src .metal
1218- sourceOffset: buf_src .offs
1219+ [encoder copyFromBuffer: bid_src .metal
1220+ sourceOffset: bid_src .offs
12191221 toBuffer: buf_dst
12201222 destinationOffset: 0
12211223 size: size];
0 commit comments