Skip to content

Commit 17a5873

Browse files
committed
[Fixup] Route ndarray + snode-accessor host reads/writes through synchronize_and_assert
1 parent eb9fda7 commit 17a5873

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

quadrants/program/ndarray.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ std::size_t Ndarray::get_nelement() const {
132132
}
133133

134134
TypedConstant Ndarray::read(const std::vector<int> &I) const {
135-
prog_->synchronize();
135+
prog_->synchronize_and_assert();
136136
size_t index = flatten_index(total_shape_, I);
137137
size_t size = data_type_size(get_element_data_type());
138138
quadrants::lang::Device::AllocParams alloc_params;
@@ -184,7 +184,7 @@ void Ndarray::write(const std::vector<int> &I, TypedConstant val) const {
184184
staging_buf_->device->unmap(*staging_buf_);
185185
staging_buf_->device->memcpy_internal(this->ndarray_alloc_.get_ptr(index * size_), staging_buf_->get_ptr(), size_);
186186

187-
prog_->synchronize();
187+
prog_->synchronize_and_assert();
188188
}
189189

190190
int64 Ndarray::read_int(const std::vector<int> &i) {

quadrants/program/snode_rw_accessors_bank.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void SNodeRwAccessorsBank::Accessors::write_float(const std::vector<int> &I, flo
4343
auto launch_ctx = writer_->make_launch_context();
4444
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
4545
launch_ctx.set_arg_float(snode_->num_active_indices, val);
46-
prog_->synchronize();
46+
prog_->synchronize_and_assert();
4747
const auto &compiled_kernel_data = get_or_compile(kernels_.writer_compiled, prog_, *writer_);
4848
prog_->launch_kernel(compiled_kernel_data, launch_ctx);
4949
// Drives invalidation of the SPIR-V per-task adstack metadata cache: a runtime adstack bound that
@@ -54,7 +54,7 @@ void SNodeRwAccessorsBank::Accessors::write_float(const std::vector<int> &I, flo
5454
}
5555

5656
float64 SNodeRwAccessorsBank::Accessors::read_float(const std::vector<int> &I) {
57-
prog_->synchronize();
57+
prog_->synchronize_and_assert();
5858
auto launch_ctx = reader_->make_launch_context();
5959
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
6060
const auto &compiled_kernel_data = get_or_compile(kernels_.reader_compiled, prog_, *reader_);
@@ -68,7 +68,7 @@ void SNodeRwAccessorsBank::Accessors::write_int(const std::vector<int> &I, int64
6868
auto launch_ctx = writer_->make_launch_context();
6969
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
7070
launch_ctx.set_arg_int(snode_->num_active_indices, val);
71-
prog_->synchronize();
71+
prog_->synchronize_and_assert();
7272
const auto &compiled_kernel_data = get_or_compile(kernels_.writer_compiled, prog_, *writer_);
7373
prog_->launch_kernel(compiled_kernel_data, launch_ctx);
7474
prog_->adstack_cache().bump_snode_write_gen(snode_->id);
@@ -79,14 +79,14 @@ void SNodeRwAccessorsBank::Accessors::write_uint(const std::vector<int> &I, uint
7979
auto launch_ctx = writer_->make_launch_context();
8080
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
8181
launch_ctx.set_arg_uint(snode_->num_active_indices, val);
82-
prog_->synchronize();
82+
prog_->synchronize_and_assert();
8383
const auto &compiled_kernel_data = get_or_compile(kernels_.writer_compiled, prog_, *writer_);
8484
prog_->launch_kernel(compiled_kernel_data, launch_ctx);
8585
prog_->adstack_cache().bump_snode_write_gen(snode_->id);
8686
}
8787

8888
int64 SNodeRwAccessorsBank::Accessors::read_int(const std::vector<int> &I) {
89-
prog_->synchronize();
89+
prog_->synchronize_and_assert();
9090
auto launch_ctx = reader_->make_launch_context();
9191
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
9292
const auto &compiled_kernel_data = get_or_compile(kernels_.reader_compiled, prog_, *reader_);
@@ -96,7 +96,7 @@ int64 SNodeRwAccessorsBank::Accessors::read_int(const std::vector<int> &I) {
9696
}
9797

9898
uint64 SNodeRwAccessorsBank::Accessors::read_uint(const std::vector<int> &I) {
99-
prog_->synchronize();
99+
prog_->synchronize_and_assert();
100100
auto launch_ctx = reader_->make_launch_context();
101101
set_kernel_args(I, snode_->num_active_indices, &launch_ctx);
102102
const auto &compiled_kernel_data = get_or_compile(kernels_.reader_compiled, prog_, *reader_);

0 commit comments

Comments
 (0)