Skip to content

Commit 8546d98

Browse files
committed
benchdnn: pad memory to page boundary
Modifies benchdnn padding to page aligned boundaries. This change should improve reliability in catching out of bound reads/writes as the virtual page table can catch invalid reads/writes crossing page boundaries.
1 parent a20e32c commit 8546d98

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/benchdnn/dnnl_memory.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,10 @@ size_t dnn_mem_t::pad_memory_size(
534534
|| engine_kind == dnnl_cpu)
535535
return sz;
536536

537-
const int pad_size = 4096;
538-
if (was_padded) *was_padded = true;
539-
return sz + pad_size;
537+
const size_t page_size = 4096;
538+
auto padded_sz = rnd_up(sz, page_size);
539+
if (was_padded) *was_padded = padded_sz != sz;
540+
return padded_sz;
540541
}
541542

542543
dnnl_memory_desc_t dnn_mem_t::pad_memory_desc(const_dnnl_memory_desc_t md,

0 commit comments

Comments
 (0)