Skip to content

Commit 4c87a0c

Browse files
pcolbergericxu233
authored andcommitted
kernel: extract streaming arguments
Signed-off-by: Peter Colberg <[email protected]>
1 parent f2e7d1a commit 4c87a0c

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/acl_kernel.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ static cl_int l_enqueue_kernel_with_type(
103103
const cl_event *event_wait_list, cl_event *event, cl_command_type type);
104104
static void l_get_arg_offset_and_size(cl_kernel kernel, cl_uint arg_index,
105105
size_t *start_idx_ret, size_t *size_ret);
106-
static cl_int
107-
l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
108-
char *buf, cl_uint *num_bytes,
109-
acl_mem_migrate_t *memory_migration);
106+
static cl_int l_copy_and_adjust_arguments_for_device(
107+
cl_kernel kernel, cl_device_id device, char *buf, cl_uint *num_bytes,
108+
acl_mem_migrate_t *memory_migration,
109+
std::vector<aocl_mmd_streaming_kernel_arg_info_t> &streaming_args);
110110

111111
static void l_abort_use_of_wrapper(acl_kernel_invocation_wrapper_t *wrapper);
112112

@@ -2178,7 +2178,7 @@ static cl_int l_enqueue_kernel_with_type(
21782178

21792179
kernel_arg_bytes = (cl_uint)l_copy_and_adjust_arguments_for_device(
21802180
kernel, device, &(invocation->arg_value[0]), &kernel_arg_bytes,
2181-
&memory_migration);
2181+
&memory_migration, serialization_wrapper->streaming_args);
21822182

21832183
assert(kernel_arg_bytes <= kernel->arg_value_size);
21842184

@@ -2242,7 +2242,7 @@ static cl_int l_enqueue_kernel_with_type(
22422242

22432243
status = l_copy_and_adjust_arguments_for_device(
22442244
kernel, device, &(invocation->arg_value[0]), &kernel_arg_bytes,
2245-
&memory_migration);
2245+
&memory_migration, wrapper->streaming_args);
22462246

22472247
if (status != CL_SUCCESS) {
22482248
ERR_RET(status, context, "Argument error");
@@ -2738,10 +2738,10 @@ int acl_num_non_null_mem_args(cl_kernel kernel) {
27382738
//
27392739
// Returns number of bytes written to the device-side buffer in num_bytes.
27402740
// Returns failure if memory could not be reserved on the device.
2741-
static cl_int
2742-
l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
2743-
char *buf, cl_uint *num_bytes,
2744-
acl_mem_migrate_t *memory_migration) {
2741+
static cl_int l_copy_and_adjust_arguments_for_device(
2742+
cl_kernel kernel, cl_device_id device, char *buf, cl_uint *num_bytes,
2743+
acl_mem_migrate_t *memory_migration,
2744+
std::vector<aocl_mmd_streaming_kernel_arg_info_t> &streaming_args) {
27452745
// indices into the host and device arg value buffer arrays.
27462746
size_t host_idx = 0;
27472747
size_t device_idx = 0;
@@ -2770,6 +2770,9 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
27702770
next_local[aspace.aspace_id] +=
27712771
l_round_up_for_alignment(aspace.static_demand);
27722772
}
2773+
2774+
streaming_args.clear();
2775+
27732776
#ifdef MEM_DEBUG_MSG
27742777
printf("kernel args\n");
27752778
#endif
@@ -2785,7 +2788,17 @@ l_copy_and_adjust_arguments_for_device(cl_kernel kernel, cl_device_id device,
27852788
// Exclude kernel argument value from device-side buffer by default.
27862789
cl_uint buf_incr = 0;
27872790

2788-
if (arg_info->addr_space == ACL_ARG_ADDR_LOCAL) {
2791+
if (arg_info->streaming_arg_info_available) {
2792+
#ifdef MEM_DEBUG_MSG
2793+
printf("streaming");
2794+
#endif
2795+
// Copy argument value to a separate buffer since it may be modified with
2796+
// clSetKernelArg() after kernel is enqueued but before it is launched.
2797+
const char *const arg_value = &kernel->arg_value[host_idx];
2798+
streaming_args.emplace_back(aocl_mmd_streaming_kernel_arg_info_t{
2799+
arg_info->streaming_arg_info.interface_name,
2800+
std::vector<char>(arg_value, arg_value + arg_info->size)});
2801+
} else if (arg_info->addr_space == ACL_ARG_ADDR_LOCAL) {
27892802
#ifdef MEM_DEBUG_MSG
27902803
printf("local");
27912804
#endif

0 commit comments

Comments
 (0)