Skip to content

Add support for general handling of trivially serializable types #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025

Conversation

leekillough
Copy link
Contributor

@leekillough leekillough commented May 9, 2025

Template metaprogramming to determine if a type is trivially serializable - that it can be read and written as raw data without any special handling.

The criteria are:

  • It is one of these types:
    • arithmetic (integral, floating-point)
    • enumeration (including std::byte)
    • pointer-to-member-object (not pointer or pointer-to-member-function)
    • std::complex<T>, C99 _Complex
    • std::bitset<N>
    • trivially copyable, standard layout aggregate type with trivially serializable members and no serialize_order() method

An aggregate is a C-style array, std::array, or a class/struct/union with all public non-static data members and direct bases, no user-provided, inherited or explicit constructors (C++17), no user-declared or inherited constructors (C++20), and no virtual functions or virtual bases.

Pointers are not considered trivially serializable since they have specific addresses which are not portable across runs, and may require special tracking and allocation. But pointers to member objects are typed offsets within a class, and are portable across runs. Pointers to member functions point to a static data structure which is not stable from run to run and is able to handle all contingencies of overriden and virtual functions.

Note: If an aggregate is a union, only the first member will be considered active, and thus cannot be a pointer. Rather than ban unions entirely, pointers in unions are strongly discouraged and can cause unexpected results.

Note: is_trivially_serializable<T> should return true if T is trivially serializable, even if there exists a specialization for serialize_impl<T>. is_trivially_serialzable<T> is a trait for trivial serializability in general, not a serialize_impl specialization test condition. For example, it returns true for arrays of int, even if serialize_impl<int[N]> is specialized.

For mapping mode, this does not change the current behavior, which only implements mapping mode for arithmetic and enumeration types which are trivially serializable. If mapping mode is required for an aggregate class type, a to_string() method and custom serialize_impl specializations are required.

std::complex, C99 _Complex, _Float16 and __float128 are supported as well, although some of them may need to be #ifdef'ed to not be included on certain platforms.

Array serialization uses the is_trivially_serializable<> trait, and calls the primitive serialization routines to serialize/deserialize the whole array as one group of bytes, if the element type is trivially serializable.

This uses C++ metaprogramming and reflection methods to determine whether an aggregate type contains any members which are not trivially serializable, such as pointers.

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v20 to check formatting

@github-actions github-actions bot added AT: CMAKE-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CMAKE-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@leekillough leekillough force-pushed the trivially_serializable branch from 098356b to 876b6ed Compare May 9, 2025 02:32
@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CLANG-FORMAT TEST - PASSED

Copy link

github-actions bot commented May 9, 2025

CMAKE-FORMAT TEST - PASSED

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL and removed AT: CLANG-FORMAT PASS labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CLANG-FORMAT TEST - FAILED (on last commit):
Run > ./scripts/clang-format-test.sh using clang-format v20 to check formatting

@github-actions github-actions bot removed the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CMAKE-FORMAT TEST - PASSED

@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT PASS and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) AT: CLANG-FORMAT FAIL labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CLANG-FORMAT TEST - PASSED

Copy link

github-actions bot commented May 9, 2025

CMAKE-FORMAT TEST - PASSED

@leekillough leekillough force-pushed the trivially_serializable branch from 36ca676 to b49fff5 Compare May 9, 2025 10:43
@github-actions github-actions bot added AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) and removed AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) labels May 9, 2025
Copy link

github-actions bot commented May 9, 2025

CMAKE-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Build Num: 2078
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Build Num: 2034
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Build Num: 2033
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Build Num: 807
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 589
  • Status: STARTED

Using Repos:

Repo: CORE (leekillough/sst-core)
  • Branch: trivially_serializable
  • SHA: 8485352
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: bb4b04da3cbca0dbf36fff9d79593f5f1db96034
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: 958a2e069e079e69996ec262cb2ce331a564c43b
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 31e2c16aa4d07b502bcd9c97b1872a0329ed0b38
  • Mode: SUPPORT_REPO

Pull Request Author: leekillough

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: 1 or more Jobs FAILED

Note: Testing will normally be attempted again in approx. 4 Hrs. If a change to the PR source branch occurs, the testing will be attempted again on next available autotester run.

Pull Request Auto Testing has FAILED (click to expand)

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Result: FAILED
  • Build #: 2078
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements/2078/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Result: FAILED
  • Build #: 2034
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2/2034/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Result: FAILED
  • Build #: 2033
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2/2033/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Result: FAILED
  • Build #: 807
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist/807/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Result: FAILED
  • Build #: 589
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements/589/consoleFull
  • Job: - Status: FAILURE

Comment on lines 204 to 208
template <>
inline constexpr bool is_trivially_serializable_v<_Float16, false> = true;

template <>
inline constexpr bool is_trivially_serializable_v<__float128, false> = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like _Float16 isn't available on the compilers on our Linux testers and _float128 isn't available on our Mac testers. We'll either need to remove these are put checks around them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed __float128 and added an #ifdef around _Float16.

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Build Num: 2079
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Build Num: 2035
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Build Num: 2034
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Build Num: 808
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 590
  • Status: STARTED

Using Repos:

Repo: CORE (leekillough/sst-core)
  • Branch: trivially_serializable
  • SHA: 8485352
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: bb4b04da3cbca0dbf36fff9d79593f5f1db96034
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: 958a2e069e079e69996ec262cb2ce331a564c43b
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 31e2c16aa4d07b502bcd9c97b1872a0329ed0b38
  • Mode: SUPPORT_REPO

Pull Request Author: leekillough

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: 1 or more Jobs FAILED

Note: Testing will normally be attempted again in approx. 4 Hrs. If a change to the PR source branch occurs, the testing will be attempted again on next available autotester run.

Pull Request Auto Testing has FAILED (click to expand)

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Result: FAILED
  • Build #: 2079
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements/2079/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Result: FAILED
  • Build #: 2035
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2/2035/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Result: FAILED
  • Build #: 2034
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2/2034/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Result: FAILED
  • Build #: 808
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist/808/consoleFull
  • Job: - Status: FAILURE

Job: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Result: FAILED
  • Build #: 590
  • URL: Jenkins server at https://sst-jenkins.sandia.gov/view/SST/job/SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements/590/consoleFull
  • Job: - Status: FAILURE

@feldergast feldergast added the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Jun 11, 2025
@leekillough leekillough force-pushed the trivially_serializable branch from 8485352 to cdbee13 Compare June 12, 2025 21:07
@github-actions github-actions bot removed the AT: WIP Mark PR as a Work in Progress (No Autotesting Performed) label Jun 12, 2025
Copy link

CLANG-FORMAT TEST - PASSED

Copy link

CMAKE-FORMAT TEST - PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
NO INSPECTION HAS BEEN PERFORMED ON THIS PULL REQUEST! - This PR must be inspected by setting label 'AT: PRE-TEST INSPECTED'.

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Test Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED by label AT: PRE-TEST INSPECTED! Autotester is Removing Label; this inspection will remain valid until a new commit to source branch is performed.

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Build Num: 2090
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Build Num: 2046
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Build Num: 2045
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Build Num: 817
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 601
  • Status: STARTED

Using Repos:

Repo: CORE (leekillough/sst-core)
  • Branch: trivially_serializable
  • SHA: cdbee13
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: bb4b04da3cbca0dbf36fff9d79593f5f1db96034
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: 958a2e069e079e69996ec262cb2ce331a564c43b
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 31e2c16aa4d07b502bcd9c97b1872a0329ed0b38
  • Mode: SUPPORT_REPO

Pull Request Author: leekillough

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Error: Jenkins Jobs - Error: [Jenkins] Cannot retrieve build running status on build ([Errno 32] Broken pipe)

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Testing Jenkins Projects:

Pull Request Auto Testing STARTING (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Build Num: 2092
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Build Num: 2048
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Build Num: 2047
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Build Num: 818
  • Status: STARTED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 603
  • Status: STARTED

Using Repos:

Repo: CORE (leekillough/sst-core)
  • Branch: trivially_serializable
  • SHA: cdbee13
  • Mode: TEST_REPO
Repo: SQE (sstsimulator/sst-sqe)
  • Branch: devel
  • SHA: bb4b04da3cbca0dbf36fff9d79593f5f1db96034
  • Mode: SUPPORT_REPO
Repo: ELEMENTS (sstsimulator/sst-elements)
  • Branch: devel
  • SHA: 958a2e069e079e69996ec262cb2ce331a564c43b
  • Mode: SUPPORT_REPO
Repo: MACRO (sstsimulator/sst-macro)
  • Branch: devel
  • SHA: 31e2c16aa4d07b502bcd9c97b1872a0329ed0b38
  • Mode: SUPPORT_REPO

Pull Request Author: leekillough

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Jenkins Testing: all Jobs PASSED

Pull Request Auto Testing has PASSED (click to expand)

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements

  • Build Num: 2092
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MR-2

  • Build Num: 2048
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-elements_MT-2

  • Build Num: 2047
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_sst-test_OMPI-4.1.4_PY3.6_sst-core_Make-Dist

  • Build Num: 818
  • Status: PASSED

Build Information

Test Name: SST__AutotestGen2_NewFW_OSX-14-XC15-ARM2_OMPI-4.1.6_PY3.10_sst-elements

  • Build Num: 603
  • Status: PASSED

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Merge Inspection' - - This Pull Request Requires Inspection... The code must be inspected by a member of the Team before Testing/Merging
THE LAST COMMIT TO THIS PULL REQUEST HAS NOT BEEN REVIEWED YET!

@sst-autotester
Copy link
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

2 similar comments
@sst-autotester
Copy link
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

@sst-autotester
Copy link
Contributor

All Jobs Finished; status = PASSED, However Inspection must be performed before merge can occur...

@sst-autotester
Copy link
Contributor

Status Flag 'Pre-Merge Inspection' - SUCCESS: The last commit to this Pull Request has been INSPECTED AND APPROVED by [ feldergast ]!

@sst-autotester
Copy link
Contributor

Status Flag 'Pull Request AutoTester' - Pull Request MUST BE MERGED MANUALLY BY Project Team - This Repo does not support Automerge

@feldergast feldergast merged commit e8f7e72 into sstsimulator:devel Jun 17, 2025
7 checks passed
@jleidel jleidel mentioned this pull request Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants