@@ -237,7 +237,6 @@ class CG_Data {
237
237
* @param[in] buffer_size The size of the given \a buffer. Used for sanity
238
238
* checking the use of the buffer.
239
239
*
240
- *
241
240
* @param[in] buffer_deleter How the given \a buffer should be deleted on
242
241
* destruction of this instance.
243
242
*
@@ -261,6 +260,9 @@ class CG_Data {
261
260
assert ( a != nullptr );
262
261
assert ( ja != nullptr );
263
262
assert ( ia != nullptr );
263
+ constexpr size_t align = (64 % sizeof (int ) == 0 )
264
+ ? 64
265
+ : (64 + (sizeof (int ) - (64 % sizeof (int ))));
264
266
if ( buffer_size < workspaceSize ( n, false ) ) {
265
267
throw std::invalid_argument ( " The given buffer size is too small" );
266
268
}
@@ -275,7 +277,7 @@ class CG_Data {
275
277
}
276
278
workspace_ptr += n * sizeof ( T );
277
279
workspace_ptr +=
278
- (sizeof ( int ) - (reinterpret_cast <uintptr_t >(workspace_ptr) % sizeof ( int ) ));
280
+ (align - (reinterpret_cast <uintptr_t >(workspace_ptr) % align ));
279
281
assert ( static_cast < char * >(buffer) + buffer_size >= workspace_ptr + n );
280
282
{
281
283
T * const workspace_vector = reinterpret_cast < T * >(workspace_ptr);
@@ -284,7 +286,7 @@ class CG_Data {
284
286
}
285
287
workspace_ptr += n * sizeof ( T );
286
288
workspace_ptr +=
287
- (sizeof ( int ) - (reinterpret_cast <uintptr_t >(workspace_ptr) % sizeof ( int ) ));
289
+ (align - (reinterpret_cast <uintptr_t >(workspace_ptr) % align ));
288
290
assert ( static_cast < char * >(buffer) + buffer_size >= workspace_ptr + n );
289
291
{
290
292
T * const workspace_vector = reinterpret_cast < T * >(workspace_ptr);
@@ -294,7 +296,7 @@ class CG_Data {
294
296
if ( buffer_size >= workspaceSize ( n, true ) ) {
295
297
workspace_ptr += n * sizeof ( T );
296
298
workspace_ptr +=
297
- (sizeof ( int ) - (reinterpret_cast <uintptr_t >(workspace_ptr) % sizeof ( int ) ));
299
+ (align - (reinterpret_cast <uintptr_t >(workspace_ptr) % align ));
298
300
assert ( static_cast < char * >(buffer) + buffer_size >= workspace_ptr + n );
299
301
T * const workspace_vector = reinterpret_cast < T * >(workspace_ptr);
300
302
grb::Vector< T > tmp = grb::internal::wrapRawVector ( n, workspace_vector );
@@ -440,7 +442,7 @@ static sparse_err_t sparse_cg_init_impl_no_buffer(
440
442
const bool support_preconditioning, const bool numa
441
443
) {
442
444
const size_t allocSize = CG_Data< T, NZI, RSI >::
443
- workspaceSize ( n, support_preconditioning );
445
+ workspaceSize ( n, support_preconditioning ) + 256 ; // TODO hide this const
444
446
void * buffer = nullptr ;
445
447
#ifdef _GRB_NO_LIBNUMA
446
448
if ( numa ) {
0 commit comments