Skip to content

Commit 5607736

Browse files
committed
aobench: use copies instead of importing host memory
1 parent 29b87e4 commit 5607736

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

samples/checkerboard/checkerboard.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ int main(int argc, char **argv)
6060
img[0] = 69;
6161
info_print("malloc'd address is: %zu\n", (size_t) img);
6262

63-
Buffer* buf = import_buffer_host(device, img, sizeof(uint8_t) * WIDTH * HEIGHT * 3);
63+
int buf_size = sizeof(uint8_t) * WIDTH * HEIGHT * 3;
64+
Buffer* buf = allocate_buffer_device(device, buf_size);
65+
copy_to_buffer(buf, 0, img, buf_size);
6466
uint64_t buf_addr = get_buffer_device_pointer(buf);
6567

6668
info_print("Device-side address is: %zu\n", buf_addr);
@@ -72,6 +74,7 @@ int main(int argc, char **argv)
7274

7375
wait_completion(launch_kernel(program, device, "main", 16, 16, 1, 1, (void*[]) { &buf_addr }));
7476

77+
copy_from_buffer(buf, 0, img, buf_size);
7578
info_print("data %d\n", (int) img[0]);
7679

7780
destroy_buffer(buf);
@@ -80,4 +83,4 @@ int main(int argc, char **argv)
8083
saveppm("ao.ppm", WIDTH, HEIGHT, img);
8184
destroy_ir_arena(a);
8285
free(img);
83-
}
86+
}

0 commit comments

Comments
 (0)