Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
28bf90d
Use CMake policy 0091 to ensure MSVC uses a static runtime for buildi…
demianmnave May 26, 2021
3202a29
Timed naive mxm for 4x4 C arrays
demianmnave May 26, 2021
87b9193
Split out uniform_random_rotation_4
demianmnave May 26, 2021
70b3b5a
Split out rotation matrix pair generator
demianmnave May 26, 2021
3e4c59c
Add get(...) overloads with mutable return types
demianmnave May 26, 2021
04203a4
Use an array of output matrices to prevent elision of the mxm code
demianmnave May 26, 2021
73f5742
Fix bugs in the random rotation matrix generator
demianmnave May 26, 2021
1795e43
Make the mxm implementation configurable via CMake
demianmnave May 26, 2021
70b1fdd
Add CML type system specializations for a 4x4 C-array (for the timing…
demianmnave May 26, 2021
3a9d252
Minor cleanup of common/traits.h
demianmnave May 26, 2021
de28ebb
Complete transition to configurable timing code (for 4x4, anyway), in…
demianmnave May 26, 2021
014b70b
Minor CMakeLists.txt cleanup to prepare for SIMD timing codes
demianmnave May 26, 2021
35e477e
Add SIMD skeleton with AVX and start of SSE4.2
demianmnave Jun 2, 2021
3cfcc28
Add iostream output for a 4x4 C-style matrix, and make N a command li…
demianmnave Jun 2, 2021
0211a54
Implement experimental SIMD 4x4 matrix products with AVX2
demianmnave Dec 1, 2024
1dc059c
Fix config and build errors
demianmnave Dec 3, 2025
7694b24
Enable c++23 and use std::chrono for timing
demianmnave Dec 3, 2025
28cdbde
Output build commands with the Ninja generator
demianmnave Dec 4, 2025
e5e67b9
Refactor compiler configuration into functions
demianmnave Dec 4, 2025
123c0c1
Minor tidying
demianmnave Dec 4, 2025
ee167ac
Introduce SIMDe for intrinsics
demianmnave Dec 4, 2025
84d630b
Indented preprocessor directives are annoying
demianmnave Dec 4, 2025
d09151b
Fixup building timing tests with vectorization
demianmnave Dec 5, 2025
52650df
Ensure clang-tools is installed
demianmnave Dec 5, 2025
db9aaf1
Unnecessary std::move()
demianmnave Dec 5, 2025
7a38c19
Drop g++-12 from the build
demianmnave Dec 5, 2025
109b246
Ubuntu 24.04 does not have g++-15
demianmnave Dec 5, 2025
f97bd5a
Default to AVX2 on Intel x64
demianmnave Dec 5, 2025
13c7418
Add 3x3 double row-major matrix product
demianmnave Dec 5, 2025
94bd3ca
Output average per-call time, not total time
demianmnave Dec 5, 2025
bc38116
Tidy up
demianmnave Dec 5, 2025
33ff522
Need margin(), not epsilon()
demianmnave Dec 8, 2025
414fd9c
Fix typo
demianmnave Dec 8, 2025
94501ac
Drop back to O2
demianmnave Dec 8, 2025
28c8a20
Tidy up a bit
demianmnave Dec 8, 2025
affe6ed
Vectorized 3x3 and 4x4 matrix product
demianmnave Dec 8, 2025
2385b92
Fix typo
demianmnave Dec 8, 2025
bf06013
Tidy up a bit
demianmnave Dec 9, 2025
bff8231
Refactor matrix products into vector-matrix primitives
demianmnave Dec 9, 2025
dc6dad6
Remove pointless test case
demianmnave Dec 9, 2025
afd7bb3
Use _v, _t for type traits
demianmnave Dec 9, 2025
53b2e65
Do not output assembly automatically
demianmnave Dec 10, 2025
1ff880f
Support testing for a traits type
demianmnave Dec 15, 2025
99019dd
More constexpr for constants
demianmnave Dec 15, 2025
97f6efa
Use a traits type for C matrices if available
demianmnave Dec 15, 2025
7bc49c6
Refactor and implement row- and columun-major matrix-vector products
demianmnave Dec 15, 2025
00f259f
Implement matrix-vector product timing tests
demianmnave Dec 15, 2025
ac37f50
Tidy up bit
demianmnave Dec 15, 2025
fdc8eea
Fix typos
demianmnave Dec 15, 2025
542dfd7
Turn off JUnit file-status reporting as CTest doesn't generate paths
demianmnave Dec 15, 2025
bc05c64
Add an experimental AGENTS.md file
demianmnave Dec 15, 2025
b1a3c5f
Tidy up vcpkg.json a bit
demianmnave Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: MultiLine
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: false
Expand Down Expand Up @@ -69,7 +69,7 @@ IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentGotoLabels: false
IndentPPDirectives: AfterHash
IndentPPDirectives: None
IndentRequires: true
IndentWidth: 2
IndentWrappedFunctionNames: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-ninja-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
shell: bash
run: |
if [ ! -x "$(command -v clang++-${{ matrix.ver }})" ]; then
sudo apt-get install -qqy --no-install-recommends clang++-${{ matrix.ver }}
sudo apt-get install -qqy --no-install-recommends clang++-${{ matrix.ver }} clang-tools-${{ matrix.ver }}
fi
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
Expand All @@ -78,7 +78,7 @@ jobs:
annotate: true
summary: true
use-suite-name: true
file-report: true
file-report: false
failed-report: true
upload-artifact: false
integrations-config: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/linux-ninja-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
fail-fast: false
matrix:
include:
- ver: "12"
- ver: "13"
- ver: "14"
env:
Expand Down Expand Up @@ -66,7 +65,7 @@ jobs:
run: |
preset="linux-ninja-gcc-s-vcpkg"
echo "Executing workflow $preset for gcc-${{ matrix.ver }} with VCPKG_ROOT @ $VCPKG_ROOT"
CC=gcc-15 CXX=g++-15 cmake --workflow --preset=$preset
cmake --workflow --preset=$preset
- name: Generate JUnit test results
uses: ctrf-io/github-test-reporter@v1
env:
Expand All @@ -78,7 +77,7 @@ jobs:
annotate: true
summary: true
use-suite-name: true
file-report: true
file-report: false
failed-report: true
upload-artifact: false
integrations-config: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-msbuild-msvc-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
annotate: true
summary: true
use-suite-name: true
file-report: true
file-report: false
failed-report: true
upload-artifact: false
integrations-config: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-ninja-clangcl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
annotate: true
summary: true
use-suite-name: true
file-report: true
file-report: false
failed-report: true
upload-artifact: false
integrations-config: |
Expand Down
156 changes: 156 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# AGENTS.md

This file provides guidance to agents when working with code in this repository.

## Build, Lint, Test, and Run Commands

### Build Commands
1. **Using CMake directly**:
- Configure:
```bash
cmake -S <path to cml-root> -G{generator name} -DBUILD_TESTING=On -DCMAKE_BUILD_TYPE=Release
```
- Build:
```bash
cmake --build . --config Release
```
- Parallel Build (e.g., 4 threads):
```bash
cmake --build . --config Release -- -j4
```

2. **Using CMake Presets**:
- List available presets:
```bash
cmake --list-presets=all
```
- Example preset-based build:
```bash
cmake --preset=windows-ninja-clangcl-mt-s-vcpkg
cmake --build --preset=windows-ninja-clangcl-mt-s-vcpkg-release
```

### Test Commands
1. **Run all tests**:
```bash
ctest -C Release
```
2. **Parallel Test Execution**:
```bash
ctest -C Release -j4
```

### Lint Commands
No explicit linting commands were found in the analyzed files.

### Run Commands
The project appears to be a library (header-only), so there are no explicit "run" commands for an application. However, the tests and timing executables can be run as described above.

## Code Style Guidelines
1. **Formatting**:
- **Column Limit**: 80 characters.
- **Indentation**: 2 spaces, no tabs.
- **Line Endings**: LF (Unix-style).
- **Insert Newline at EOF**: Enabled.

2. **Braces**:
- **After Class/Struct/Enum/Function**: Always place braces on a new line.
- **Control Statements**: No braces for single-line statements.

3. **Alignment**:
- **Trailing Comments**: Aligned.
- **Operands**: No alignment.
- **Pointer Alignment**: Left-aligned (`int* ptr`).

4. **Spaces**:
- **Before Parentheses**: None (e.g., `if(condition)`).
- **Around Operators**: Space before assignment operators.
- **In Empty Blocks/Parentheses**: None.

5. **Includes**:
- **Sorting**: Disabled.
- **Blocks**: Preserve original order.

6. **Miscellaneous**:
- **Short Functions**: Inline only.
- **Short If Statements**: Allowed on a single line.
- **Namespace Indentation**: None.
- **Header Include Guards**: Use `#pragma once` only, never `#ifdef/#endif` guards.

7. **New Files**:
- **File Naming**: Use descriptive names that reflect the content of the file.
- **File Extension for C++**: `.cpp`, `.h`, `.inl`, `.tpp`, `.hpp`.
- **File header**: Use the default file header for all new files.

8. **Comments**:
- **C++ Comment Style**: Use C comment delimiters for C++ files.
- **Short Comments**: Allowed on a single line if they are short.
- **Long Comments**: Aligned at the beginning of the block.


### Standard File Headers by Language
1. C++:
```cpp
/*-------------------------------------------------------------------------
@@COPYRIGHT@@
*-----------------------------------------------------------------------*/
```

2. Python
```python
#*-------------------------------------------------------------------------
# @@COPYRIGHT@@
#*-------------------------------------------------------------------------
```

## Core Architecture and Components
1. **Vectors (`cml/vector/`)**:
- Provides various vector types (e.g., fixed, dynamic, external).
- Includes operations like dot product, cross product, and normalization.
- Supports expression templates for efficient computation.

2. **Matrices (`cml/matrix/`)**:
- Implements matrix types and operations (e.g., inversion, transformation).
- Includes support for fixed and dynamic sizes.
- Provides utilities for matrix concatenation and basis generation.

3. **Quaternions (`cml/quaternion/`)**:
- Encapsulates quaternion operations for rotations and transformations.
- Includes scalar and vector operations on quaternions.
- Provides utilities for normalization, inversion, and logarithmic operations.

4. **Storage (`cml/storage/`)**:
- Defines storage strategies for vectors, matrices, and quaternions.
- Includes dynamic, fixed, and external storage types.
- Provides utilities for resizing and reshaping storage.

5. **Utilities (`cml/util/`)**:
- Contains helper functions for printing and hashing.
- Includes mathematical utilities for field-of-view conversions and more.

6. **Testing (`tests/`)**:
- Organized into subdirectories for each core component (e.g., `vector`, `matrix`, `quaternion`).
- Uses Catch2 for unit testing.
- Includes timing tests for performance evaluation.

## Testing Setup
1. **Framework**:
- The project uses **Catch2** for unit testing.
- The main entry point for tests is defined in [`tests/main/catch_main.cpp`](tests/main/catch_main.cpp:11), which initializes the Catch2 session.

2. **Test Organization**:
- Tests are organized into subdirectories under `tests/`, corresponding to the core components.

3. **Test Execution**:
- Build the tests:
```bash
cmake --build . --config Release
```
- Run the tests:
```bash
ctest -C Release
```

4. **Timing Tests**:
- Timing tests are conditionally included if `BUILD_TIMING` is enabled in the CMake configuration.
- These tests are located in the `tests/timing/` directory.
36 changes: 30 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ endif()
# Standard includes:
include(CMakeDependentOption)

# Allow disabling SIMD:
if(NOT DEFINED CML_DISABLE_SIMD)
option(CML_DISABLE_SIMD "Disable vectorization (also disables timing tests)" OFF)
endif()

# Build tests if requested:
if(NOT DEFINED BUILD_TESTING)
option(BUILD_TESTING "Build CML tests" OFF)
endif()

if(NOT DEFINED BUILD_TIMING)
cmake_dependent_option(BUILD_TIMING
"Build timing tests (requires SIMD)" OFF
"CML_DISABLE_SIMD" OFF
)
endif()

if(NOT DEFINED BUILD_SHARED_LIBS)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
endif()
Expand All @@ -37,10 +54,8 @@ endif()
if(NOT DEFINED CML_ENABLE_RELATIVE_TEST_PATHS)
# Force CTest to use relative paths. Primarily for automated testing:
cmake_dependent_option(CML_ENABLE_RELATIVE_TEST_PATHS
"Make test executable paths relative to CMAKE_BINARY_DIR"
OFF # Show and default to OFF if...
"BUILD_TESTING"
OFF # Otherwise, default to OFF.
"Make test executable paths relative to CMAKE_BINARY_DIR" OFF
"BUILD_TESTING" OFF
)
endif()

Expand All @@ -50,7 +65,16 @@ endif()

list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(default-paths)
include(${CMAKE_CXX_COMPILER_ID}-compiler)
include(configure-compiler)

# SIMDe is required when SIMD is enabled:
if(NOT CML_DISABLE_SIMD)
set(_hints)
if(DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
list(APPEND _hints HINTS "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
endif()
find_path(SIMDE_INCLUDE_DIR NAMES "simde/simde-common.h" ${_hints})
endif()

# Create the CML interface library:
add_subdirectory(cml)
Expand Down Expand Up @@ -100,4 +124,4 @@ install(
export(
EXPORT Targets
FILE "${CMAKE_BINARY_DIR}/${CML_INSTALL_CMAKEDIR}/${_TARGET_FILE}"
)
)
22 changes: 17 additions & 5 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
"cmake/presets/vcpkg.json"
],
"configurePresets": [
{
"name": ".timing",
"hidden": true,
"description": "Build timing executables",
"cacheVariables": {
"BUILD_TIMING": {
"type": "BOOL",
"value": true
}
}
},

{
"name": "linux-ninja-clang-s",
"description": "Linux Ninja configuration using clang++-${ENV_COMPILER_VERSION}",
Expand All @@ -18,13 +30,13 @@
{
"name": "linux-ninja-clang-s-vcpkg",
"description": "Linux Ninja configuration using clang++-${ENV_COMPILER_VERSION} and vcpkg",
"inherits": [ ".linux-ninja-clang", ".static", ".vcpkg-linux-any-static", ".testing" ]
"inherits": [ ".linux-ninja-clang", ".static", ".vcpkg-linux-any-static", ".testing", ".timing" ]
},

{
"name": "linux-ninja-gcc-s-vcpkg",
"description": "Linux Ninja configuration using g++-${ENV_COMPILER_VERSION} and vcpkg",
"inherits": [ ".linux-ninja-gcc", ".static", ".vcpkg-linux-any-static", ".testing" ]
"inherits": [ ".linux-ninja-gcc", ".static", ".vcpkg-linux-any-static", ".testing", ".timing" ]
},

{
Expand All @@ -36,19 +48,19 @@
{
"name": "windows-ninja-clangcl-mt-s-vcpkg",
"description": "Windows Ninja configuration using clang-cl.ex and vcpkg",
"inherits": [ ".windows-ninja-clangcl", ".static", ".vcpkg-windows-clangcl-static", ".testing" ]
"inherits": [ ".windows-ninja-clangcl", ".static", ".vcpkg-windows-clangcl-static", ".testing", ".timing" ]
},

{
"name": "windows-msbuild-msvc-17-mt-s-vcpkg",
"description": "Windows MSBuild configuration using ${MSVC_TOOLSET_VERSION} and vcpkg",
"inherits": [ ".windows-msbuild-msvc-17", ".static", ".vcpkg-windows-msvc-static", ".testing" ]
"inherits": [ ".windows-msbuild-msvc-17", ".static", ".vcpkg-windows-msvc-static", ".testing", ".timing" ]
},

{
"name": "windows-msbuild-clangcl-17-mt-s-vcpkg",
"description": "Windows MSBuild configuration using ClangCL and vcpkg",
"inherits": [ ".windows-msbuild-clangcl-17", ".static", ".vcpkg-windows-clangcl-static", ".testing" ]
"inherits": [ ".windows-msbuild-clangcl-17", ".static", ".vcpkg-windows-clangcl-static", ".testing", ".timing" ]
}
],
"buildPresets": [
Expand Down
Loading
Loading