File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,7 @@ class TritonJITFunction;
1313
1414template <typename T>
1515T get_next_multiple_of (T pos, T step) {
16- if (pos % step == 0 ) return pos;
17-
18- while (pos % step) {
19- pos++;
20- }
21- return pos;
16+ return ((pos + step - 1 ) / step) * step;
2217}
2318
2419struct ParameterBuffer {
@@ -34,11 +29,13 @@ struct ParameterBuffer {
3429
3530 template <typename T>
3631 void push_arg (T &&v) {
37- size_t align = alignof (T);
32+ using U = std::decay_t <T>;
33+ static_assert (std::is_trivially_copyable_v<U>, " Non trivially copyable type" );
34+ size_t align = alignof (U);
3835 size_t offset = get_next_multiple_of (this ->cursor_ , align);
3936 this ->offsets_ .push_back (offset);
4037
41- size_t size = sizeof (T );
38+ size_t size = sizeof (U );
4239 this ->buff_ .resize (offset + size);
4340 std::byte *ptr = this ->buff_ .data () + offset;
4441 std::memcpy (ptr, &v, size);
You can’t perform that action at this time.
0 commit comments