void single(char *dst, char *const *src) { // Allocate a temporary buffer on the heap array buffer = empty(buffer_tp); char *buffer_data = buffer.get_readwrite_originptr(); ckernel_prefix *first = get_child_ckernel(); expr_single_t first_func = first->get_function<expr_single_t>(); ckernel_prefix *second = get_child_ckernel(second_offset); expr_single_t second_func = second->get_function<expr_single_t>(); first_func(buffer_data, src, first); second_func(dst, &buffer_data, second); }
void destruct_children() { // The first child ckernel get_child_ckernel()->destroy(); // The second child ckernel destroy_child_ckernel(second_offset); }
void strided(char *dst, intptr_t dst_stride, char *const *src, const intptr_t *src_stride, size_t count) { // Allocate a temporary buffer on the heap array buffer = empty(buffer_shape[0], buffer_tp); char *buffer_data = buffer.get_readwrite_originptr(); intptr_t buffer_stride = reinterpret_cast<const fixed_dim_type_arrmeta *>( buffer.get_arrmeta())->stride; ckernel_prefix *first = get_child_ckernel(); expr_strided_t first_func = first->get_function<expr_strided_t>(); ckernel_prefix *second = get_child_ckernel(second_offset); expr_strided_t second_func = second->get_function<expr_strided_t>(); char *src0 = src[0]; intptr_t src0_stride = src_stride[0]; size_t chunk_size = std::min(count, static_cast<size_t>(DYND_BUFFER_CHUNK_SIZE)); first_func(buffer_data, buffer_stride, &src0, src_stride, chunk_size, first); second_func(dst, dst_stride, &buffer_data, &buffer_stride, chunk_size, second); count -= chunk_size; while (count) { src0 += chunk_size * src0_stride; dst += chunk_size * dst_stride; reset_strided_buffer_array(buffer); chunk_size = std::min(count, static_cast<size_t>(DYND_BUFFER_CHUNK_SIZE)); first_func(buffer_data, buffer_stride, &src0, src_stride, chunk_size, first); second_func(dst, dst_stride, &buffer_data, &buffer_stride, chunk_size, second); count -= chunk_size; } }
/** * Returns the child ckernel immediately following this one. */ inline ckernel_prefix *get_child_ckernel() { return get_child_ckernel(sizeof(self_type)); }