Skip to content

Avoid std::back_insert_iterator of fmt::memory_buffer in fmt::format#397

Merged
oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:get-ready-for-fmt-12
Jun 30, 2026
Merged

Avoid std::back_insert_iterator of fmt::memory_buffer in fmt::format#397
oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:get-ready-for-fmt-12

Conversation

@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator

closes #396

fmt 12.2 changed the implementation path used by fmt::format_to with std::back_insert_iterator. Under nvcc, that path rejects std::back_insert_iterator<fmt::memory_buffer> because fmt’s constexpr helper takes a non-literal iterator type. Replacing std::back_inserter(buffer) with fmt::appender(buffer) for fmt::memory_buffer outputs avoids that path and is the fmt-native way to append to memory_buffer.

…::format

fmt 12.2 changed the implementation path used by `fmt::format_to` with
`std::back_insert_iterator`. Under nvcc, that path rejects
`std::back_insert_iterator<fmt::memory_buffer>` because fmt’s constexpr helper
takes a non-literal iterator type. Replacing `std::back_inserter(buffer)` with
`fmt::appender(buffer)` for `fmt::memory_buffer` outputs avoids that path and is
the fmt-native way to append to `memory_buffer`.
@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

This comment was marked as outdated.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Updated several output-generation paths to use a more efficient formatting approach.
    • Kept CSV and Markdown output content and structure unchanged.
  • Tests
    • Aligned test output-building code with the updated formatting approach.
    • No changes to expected results or test behavior.

Walkthrough

All fmt::format_to calls writing into fmt::memory_buffer instances replace std::back_inserter(buffer) with fmt::appender(buffer) across library source (csv_printer, markdown_printer, markdown_table, state) and test files. markdown_table::to_string() additionally replaces its std::vector<char> intermediate buffer with fmt::memory_buffer.

fmt::appender migration

Layer / File(s) Summary
Library formatters
nvbench/csv_printer.cu, nvbench/markdown_printer.cu, nvbench/internal/markdown_table.cuh, nvbench/state.cxx
All production fmt::format_to calls into fmt::memory_buffer switch to fmt::appender; markdown_table::to_string() also replaces its std::vector<char> + std::back_inserter buffer with fmt::memory_buffer + fmt::appender + fmt::to_string.
Test helpers and test functions
testing/axes_metadata.cu, testing/benchmark.cu, testing/create.cu, testing/option_parser.cu, testing/runner.cu, testing/state_generator.cu
All test-side fmt::format_to calls into fmt::memory_buffer switch from std::back_inserter to fmt::appender; no test logic, expected strings, or control flow changed.

Assessment against linked issues

Objective Addressed Explanation
Replace std::back_inserter(buffer) with fmt::appender(buffer) when writing into fmt::memory_buffer to fix compilation with fmt 12.2 [#396]
For code using std::vector<char> + std::back_inserter solely to build a string, switch to fmt::memory_buffer + fmt::appender [#396]

Comment @coderabbitai help to get the list of available commands.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 30, 2026
@oleksandr-pavlyk oleksandr-pavlyk moved this from Todo to In Progress in CCCL Jun 30, 2026
@oleksandr-pavlyk oleksandr-pavlyk moved this from In Progress to In Review in CCCL Jun 30, 2026
@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator Author

The CI run using fmt 11.2 is green. I also opened #398 where version of fmt was bumped to 12.2 and also includes this change. That build is green as well.

@oleksandr-pavlyk oleksandr-pavlyk enabled auto-merge (squash) June 30, 2026 17:23
@oleksandr-pavlyk oleksandr-pavlyk merged commit 21ff86c into NVIDIA:main Jun 30, 2026
60 checks passed
@oleksandr-pavlyk oleksandr-pavlyk deleted the get-ready-for-fmt-12 branch June 30, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Compilation error with upgrade of FMT library to 12.2

2 participants