Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/asahi/vulkan/00-hk-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
violation.
-->
<option name="hk_mutable_format_srgb_pair" value="true" />
<!--
Submit at most two commands per kernel ioctl, so the GPU starts
work from the first ioctl while the kernel validates later
ioctls. The gain was measured on the M5 Max only.
-->
<option name="hk_submit_batch_size" value="2" />
</application>

<application name="llama.cpp (ggml-vulkan)" application_name_match="^ggml-vulkan$">
Expand Down
4 changes: 4 additions & 0 deletions src/asahi/vulkan/hk_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ hk_CreateDevice(VkPhysicalDevice physicalDevice,
goto fail_fd;
}

/* Splitting a long submission lets the GPU start work from the first ioctl
* while the kernel validates later ioctls, so a profile may cap batch size. */
dev->submit_batch_size = instance->drirc.performance.submit_batch_size;

vk_device_set_drm_fd(&dev->vk, dev->dev.fd);
dev->vk.copy_sync_payloads = vk_drm_syncobj_copy_payloads;
dev->vk.command_buffer_ops = &hk_cmd_buffer_ops;
Expand Down
3 changes: 3 additions & 0 deletions src/asahi/vulkan/hk_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ struct hk_device {
} scratch;

uint32_t perftest;
/* drirc hk_submit_batch_size: at most this many commands per kernel
* submission (0: the kernel and batching limits alone). */
unsigned submit_batch_size;

struct {
struct u_rwlock lock;
Expand Down
6 changes: 5 additions & 1 deletion src/asahi/vulkan/hk_drirc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def declare_options():

debug_options = []
features_options = []
performance_options = []
performance_options = [
drirc_gen.DrircInt("hk_submit_batch_size", 0, 0, 64,
"Maximum GPU commands per kernel submission "
"(0 uses the driver default)", c_name="submit_batch_size"),
]

drirc_gen.add_common_vk_options(debug_options, features_options, misc_options,
valid_options=VALID_COMMON_VK_OPTIONS,
Expand Down
3 changes: 2 additions & 1 deletion src/asahi/vulkan/hk_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ asahi_append_fragment_attachments(struct hk_device *dev,
static inline unsigned
max_commands_per_submit(struct hk_device *dev)
{
return hk_drm_submit_command_limit(
unsigned limit = hk_drm_submit_command_limit(
dev->dev.chip != AGX_CHIP_G13X && !HK_PERF(dev, NOBATCH),
dev->dev.params.max_commands_per_submission);
return dev->submit_batch_size ? MIN2(limit, dev->submit_batch_size) : limit;
}

static VkResult
Expand Down
Loading