Skip to content

Commit

Permalink
[trajoptlib] Upgrade Sleipnir for more efficient sparsity logging (#1138
Browse files Browse the repository at this point in the history
)
  • Loading branch information
calcmogul authored Jan 10, 2025
1 parent f9108be commit db7926f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions trajoptlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ set(BUILD_EXAMPLES OFF)
fetchcontent_declare(
Sleipnir
GIT_REPOSITORY https://github.com/SleipnirGroup/Sleipnir
# main on 2025-01-08
GIT_TAG 3b3df2fe485743ab73f395158d0225ad87d9e67c
# main on 2025-01-09
GIT_TAG 8c2cbe77e1ff319c825b9c908e4a31272c561b61
PATCH_COMMAND
git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/0001-Downgrade-to-C-20.patch
UPDATE_DISCONNECTED 1
Expand Down
32 changes: 30 additions & 2 deletions trajoptlib/cmake/0001-Downgrade-to-C-20.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <[email protected]>
Date: Wed, 8 Jan 2025 23:39:34 -0800
Date: Thu, 9 Jan 2025 22:23:08 -0800
Subject: [PATCH] Downgrade to C++20

---
Expand All @@ -10,7 +10,8 @@ Subject: [PATCH] Downgrade to C++20
include/.styleguide | 1 +
include/sleipnir/autodiff/Expression.hpp | 57 +++++++++++-------------
include/sleipnir/util/Print.hpp | 27 +++++------
6 files changed, 53 insertions(+), 45 deletions(-)
include/sleipnir/util/Spy.hpp | 8 +++-
7 files changed, 60 insertions(+), 46 deletions(-)

diff --git a/.styleguide b/.styleguide
index 2cf272a115102886134455a87ea5c7dcf7188283..76e25473e77ab7838509eaeeefa7170a06507f8c 100644
Expand Down Expand Up @@ -368,3 +369,30 @@ index a746cb77b70f095bb15f4c493295cb925bc74cd3..484d1b2bec7148c5b9affccbf554c7df
} catch (const std::system_error&) {
}
}
diff --git a/include/sleipnir/util/Spy.hpp b/include/sleipnir/util/Spy.hpp
index 1abeb469a43d3d644efc1ad0e06e43928149ed0a..ae112430d7609356748b81d5dc4d0b5a7bac0ca1 100644
--- a/include/sleipnir/util/Spy.hpp
+++ b/include/sleipnir/util/Spy.hpp
@@ -4,7 +4,10 @@

#include <stdint.h>

+#include <algorithm>
+#include <array>
#include <bit>
+#include <cstddef>
#include <fstream>
#include <string>
#include <string_view>
@@ -112,7 +115,10 @@ class SLEIPNIR_DLLEXPORT Spy {
*/
void Write32le(int32_t num) {
if constexpr (std::endian::native != std::endian::little) {
- num = std::byteswap(num);
+ auto value_representation =
+ std::bit_cast<std::array<std::byte, sizeof(int32_t)>>(num);
+ std::ranges::reverse(value_representation);
+ num = std::bit_cast<int32_t>(value_representation);
}
m_file.write(reinterpret_cast<char*>(&num), sizeof(num));
}

0 comments on commit db7926f

Please sign in to comment.