Skip to content

Support string constexpr kernel args; scope googletest to examples#32

Merged
tengqm merged 1 commit into
masterfrom
fix/string-constexpr-arg
Jul 13, 2026
Merged

Support string constexpr kernel args; scope googletest to examples#32
tengqm merged 1 commit into
masterfrom
fix/string-constexpr-arg

Conversation

@tengqm

@tengqm tengqm commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Two independent fixes surfaced while building FlagGems' C++ operators against this library on the Enflame (GCU) backend.

1. String constexpr arguments failed to compile

ArgHandle::handle_arg_plain() routes every non-Tensor / non-nullopt argument through a runtime branch whose handlers (handle_specialized, handle_specialized_no_alignment, handle_non_constexpr) all evaluate triton_type<T>::name. For a string argument — e.g. a dtype spelled "tl.float32", passed by FlagGems' GCU mm kernel — triton_type has no specialization, so the template failed to instantiate:

error: 'name' is not a member of 'triton_jit::triton_type<const char*>'

even though a string argument is always a constexpr Triton parameter at runtime. The CUDA path never passed a string, so it compiled.

Fix: add a compile-time else if constexpr for const char* / char* / std::string / std::string_view that routes strings straight to handle_constexpr, mirroring the existing nullopt handling, so the specialized / non-constexpr paths are never instantiated for a string type.

2. googletest fetched unconditionally

add_subdirectory(src) precedes the googletest fetch, so the library itself never needs gtest — only the examples do. But the FetchContent(googletest) sat outside the TRITON_JIT_BUILD_EXAMPLES guard, so every subdirectory consumer (e.g. FlagGems via FetchContent) downloaded googletest anyway.

Fix: move the googletest fetch inside the TRITON_JIT_BUILD_EXAMPLES block.

Verification

FlagGems' flag-gems-cpp-gcu extension now builds against this library with no string-arg compile error and no googletest download.

🤖 Generated with Claude Code

Two independent fixes surfaced while building FlagGems' C++ operators
against this library on the Enflame (GCU) backend.

1. String constexpr arguments failed to compile. handle_arg_plain()
   routes every non-Tensor / non-nullopt argument through a runtime
   branch whose four handlers all evaluate triton_type<T>::name. For a
   string argument (e.g. a dtype spelled "tl.float32", passed by
   FlagGems' GCU mm kernel) triton_type has no specialization, so the
   template failed to instantiate even though such an argument is always
   a constexpr Triton parameter at runtime. Add a compile-time
   `else if constexpr` for const char* / char* / std::string /
   std::string_view that routes strings straight to handle_constexpr,
   mirroring the existing nullopt handling, so the specialized /
   non-constexpr paths are never instantiated for a string type.

2. googletest was fetched unconditionally, even for subdirectory
   consumers that only build the library. add_subdirectory(src) precedes
   the fetch, so the library itself never needs gtest -- only the
   examples do. Move the FetchContent(googletest) inside the
   TRITON_JIT_BUILD_EXAMPLES guard so FetchContent consumers (e.g.
   FlagGems) no longer download googletest.

Verified: FlagGems' flag-gems-cpp-gcu extension now builds against this
library with no string-arg compile error and no googletest download.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tengqm tengqm merged commit 50a4259 into master Jul 13, 2026
3 checks passed
@tengqm tengqm deleted the fix/string-constexpr-arg branch July 13, 2026 03:28
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