Skip to content

Commit

Permalink
Merge pull request #718 from PowerGridModel/feature/re-route-benchmar…
Browse files Browse the repository at this point in the history
…k-validation-tests

Feature/Re route validation tests
  • Loading branch information
mgovers authored Oct 7, 2024
2 parents 937b6f3 + e8f0c8b commit dd0d1b0
Show file tree
Hide file tree
Showing 3 changed files with 338 additions and 281 deletions.
9 changes: 7 additions & 2 deletions power_grid_model_c/power_grid_model_c/src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ using meta_data::RawDataPtr;

// buffer control
RawDataPtr PGM_create_buffer(PGM_Handle* /* handle */, PGM_MetaComponent const* component, PGM_Idx size) {
// alignment should be maximum of alignment of the component and alignment of void*
size_t const alignment = std::max(component->alignment, sizeof(void*));
// total bytes should be multiple of alignment
size_t const requested_bytes = component->size * size;
size_t const rounded_bytes = ((requested_bytes + alignment - 1) / alignment) * alignment;
#ifdef _WIN32
return _aligned_malloc(component->size * size, component->alignment);
return _aligned_malloc(rounded_bytes, alignment);
#else
return std::aligned_alloc(component->alignment, component->size * size);
return std::aligned_alloc(alignment, rounded_bytes);
#endif
}
void PGM_destroy_buffer(RawDataPtr ptr) {
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp_validation_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_executable(power_grid_model_validation_tests ${PROJECT_SOURCES})

target_link_libraries(power_grid_model_validation_tests
PRIVATE
power_grid_model
power_grid_model_cpp
doctest::doctest
nlohmann_json nlohmann_json::nlohmann_json
)
Expand Down
Loading

0 comments on commit dd0d1b0

Please sign in to comment.