Skip to content

fix: set tag type to uint8_t#437

Merged
gouarin merged 3 commits into
hpc-maths:mainfrom
gouarin:tag-uint8
Apr 30, 2026
Merged

fix: set tag type to uint8_t#437
gouarin merged 3 commits into
hpc-maths:mainfrom
gouarin:tag-uint8

Conversation

@gouarin
Copy link
Copy Markdown
Contributor

@gouarin gouarin commented Mar 21, 2026

Description

This PR updates the internal representation of cell tagging flags by making samurai::CellFlag use an 8-bit underlying type and adjusting call sites to cast to std::uint8_t when writing/reading tag bitmasks.

Changes:

  • Change CellFlag to enum class CellFlag : std::uint8_t.
  • Update tagging code paths to use static_cast<std::uint8_t>(CellFlag::...) instead of static_cast<int>(...).

Code of Conduct

By submitting this PR, you agree to follow our Code of Conduct

  • I agree to follow this project's Code of Conduct

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 29, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · -1 duplication

Metric Results
Complexity 0
Duplication -1

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the internal representation of cell tagging flags by making samurai::CellFlag use an 8-bit underlying type and adjusting call sites to cast to std::uint8_t when writing/reading tag bitmasks.

Changes:

  • Change CellFlag to enum class CellFlag : std::uint8_t.
  • Update tagging code paths to use static_cast<std::uint8_t>(CellFlag::...) instead of static_cast<int>(...).
  • Reformat a small block in algorithm/utils.hpp while updating casts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
include/samurai/cell_flag.hpp Switch CellFlag underlying type to std::uint8_t.
include/samurai/io/from_geometry.hpp Update tag assignments/bit-tests to use std::uint8_t casts.
include/samurai/algorithm/utils.hpp Update keep-tag propagation to use std::uint8_t casts and minor formatting.
include/samurai/algorithm/update.hpp Update coarsen/keep/refine mask checks to use std::uint8_t casts.
include/samurai/algorithm/graduation.hpp Update refine/keep mask propagation and tag checks to use std::uint8_t casts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

namespace samurai
{
enum class CellFlag
enum class CellFlag : std::uint8_t
[&](std::size_t level, const auto& i, const auto& index)
{
tag(level, i, index[0], index[1]) = static_cast<int>(CellFlag::keep);
tag(level, i, index[0], index[1]) = static_cast<std::uint8_t>(CellFlag::keep);
Comment on lines 5 to 10
#pragma once

namespace samurai
{
enum class CellFlag
enum class CellFlag : std::uint8_t
{
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the size of the cell tagging bitmask by making samurai::CellFlag explicitly use an 8-bit underlying type (std::uint8_t) and updates key tagging call sites to operate on std::uint8_t values consistently.

Changes:

  • Switch samurai::CellFlag to enum class CellFlag : std::uint8_t (and include <cstdint>).
  • Store geometry-import tag fields as std::uint8_t instead of int.
  • Update adaptation/tagging bitmask reads/writes to cast CellFlag values to std::uint8_t.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
include/samurai/cell_flag.hpp Defines CellFlag with std::uint8_t underlying type and adds <cstdint> include.
include/samurai/io/from_geometry.hpp Changes the internal tag scalar field storage to std::uint8_t and updates assignments/bit tests accordingly.
include/samurai/algorithm/utils.hpp Updates CellFlag bitwise OR writes to std::uint8_t (with one remaining static_cast<int>(flag) noted).
include/samurai/algorithm/update.hpp Updates refine/keep/coarsen bitmask checks to use std::uint8_t casts.
include/samurai/algorithm/graduation.hpp Updates refine/keep/coarsen bitmask checks and propagation to use std::uint8_t casts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/samurai/algorithm/utils.hpp Outdated
@@ -123,15 +123,16 @@ namespace samurai
{
auto mask = (tag(level, i, j, k) & static_cast<int>(flag));
@gouarin gouarin merged commit 44e2ce7 into hpc-maths:main Apr 30, 2026
17 checks passed
@gouarin gouarin deleted the tag-uint8 branch April 30, 2026 05:46
gouarin added a commit that referenced this pull request May 4, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.30.0](v0.29.2...v0.30.0)
(2026-05-04)


### Features

* ND projection and prediction operator
([#435](#435))
([55829ab](55829ab))


### Bug Fixes

* mesh_config in load
([#438](#438))
([7f43222](7f43222))
* set tag type to `uint8_t`
([#437](#437))
([44e2ce7](44e2ce7))


### Performance Improvements

* improve tag computation
([#436](#436))
([b0aadc5](b0aadc5))
* optimizations of local non-linear solvers
([#439](#439))
([f0eedea](f0eedea))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants