Skip to content

Comments

Automatically mark read-only lambda captures as constant#392

Open
davidbeckingsale wants to merge 23 commits intomainfrom
task/auto-lambda-const
Open

Automatically mark read-only lambda captures as constant#392
davidbeckingsale wants to merge 23 commits intomainfrom
task/auto-lambda-const

Conversation

@davidbeckingsale
Copy link
Collaborator

No description provided.

davidbeckingsale and others added 18 commits January 20, 2026 14:19
This header provides infrastructure for auto-detecting read-only lambda
captures at JIT compilation time. It includes:

- CaptureInfo struct to track capture metadata (offset, slot, type)
- analyzeReadOnlyCaptures() to identify read-only scalar captures
- isSupportedScalarType() to filter supported types (i1, i8, i32, i64, float, double)
- pointerEscapes() for conservative escape analysis
- mergeCaptures() to combine auto-detected and explicit captures

This is the foundation for automatic specialization of read-only captures,
reducing the need for explicit jit_variable annotations.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…evice

This change integrates the auto-detection of read-only lambda captures
into the GPU JIT compilation path (JitEngineDevice::compileAndRun).

Key changes:
- Added AutoReadOnlyCaptures.h include to JitEngineDevice.h
- Added traceOutAuto overload for RuntimeConstant in AutoReadOnlyCaptures.h
  to enable tracing of auto-detected captures during extraction
- Modified getLambdaJitValues to accept KernelArgs parameter and perform
  auto-detection when PROTEUS_AUTO_READONLY_CAPTURES is enabled
- Added findLambdaArgIndex helper to determine lambda argument position
- Auto-detected captures are merged with explicit jit_variable() captures,
  with explicit captures taking precedence
- Auto-detected captures are traced with [LambdaSpec][Auto] prefix
- Updated compileAndRun to pass KernelArgs to getLambdaJitValues
- Auto-detected captures are included in hash computation for correct caching

The implementation follows the flow:
1. Analyze lambda function IR for read-only captures
2. Extract capture values from lambda closure in KernelArgs
3. Merge with explicit captures (explicit takes precedence)
4. Trace auto-detected captures
5. Include merged captures in specialization hash

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit implements automatic detection and extraction of read-only lambda
captures in the CPU JIT compilation path (JitEngineHost), completing the
integration of the auto-readonly capture feature for host execution.

Changes:
- Modified JitEngineHost.cpp to include AutoReadOnlyCaptures.h
- Extended getLambdaJitValues() to perform auto-detection when enabled:
  * Analyzes IR to identify read-only captures using analyzeReadOnlyCaptures()
  * Infers closure type from lambda function arguments
  * Extracts capture values from lambda closure memory
  * Merges auto-detected captures with explicit jit_variable() captures
  * Generates [LambdaSpec][Auto] trace output for auto-detected captures
- Updated specializeIR() signature to accept merged lambda capture values
- Auto-detected captures are included in hash computation for cache correctness
- Feature respects PROTEUS_AUTO_READONLY_CAPTURES configuration option

The implementation follows the same pattern as JitEngineDevice, with
adaptations for the host JIT execution model where the lambda closure is
passed directly as Args[0].

All lambda tests pass, including tests for explicit captures, auto-detected
captures, mixed captures, and written (non-readonly) captures.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit makes progress toward enabling auto-readonly lambda capture
detection for CPU/host JIT execution, but the feature remains incomplete
due to missing closure pointer plumbing in the ProteusPass.

Changes made:
- Modified LambdaRegistry::registerLambda() to always register lambda types
  in the map, even when there are no explicit jit_variable() calls. This
  allows matchJitVariableMap() to find lambdas that rely solely on auto-
  detection.

- Updated tests/cpu/lambda_auto_readonly.cpp to enable auto-detection
  (PROTEUS_AUTO_READONLY_CAPTURES=1) and add CHECK-DAG assertions for
  [LambdaSpec][Auto] trace output, matching the GPU test configuration.

Root cause of remaining issue:
The auto-detection logic in getLambdaJitValues() requires the lambda
closure pointer to extract capture values from memory. For host JIT, this
pointer should be passed as Args[0]. However, the ProteusPass currently
only populates Args when there are explicit jit_variable() calls. For
lambdas with pure auto-detection (no jit_variable calls), Args is NULL,
preventing auto-detection from running.

Next steps:
The ProteusPass needs to be modified to ALWAYS pass the lambda closure
pointer (the 'this' pointer of the lambda operator()) as Args[0], even
when there are no explicit jit_variable() calls. This is the "closure
pointer plumbing" referenced in proteus-0sf.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit completes the integration of auto-readonly lambda capture
detection for CPU/host JIT execution, fixing the missing trace lines issue
reported in proteus-oub.

Root Causes Fixed:
1. ProteusPass was not passing Args when there were no explicit jit_variable()
   calls, preventing auto-detection from accessing the lambda closure pointer
2. AutoReadOnlyCaptures analysis only handled typed struct GEPs, but host IR
   uses byte-offset GEPs after optimization
3. ClosureType inference failed for byte-offset GEPs, requiring fallback to
   direct byte-offset extraction

Changes:
- src/pass/ProteusPass.cpp: Modified emitJitEntryCall() to always create Args
  array for lambda functions (detected by ::operator() in demangled name), even
  when NumRuntimeConstants == 0. This ensures the lambda closure pointer is
  available for auto-detection.

- include/proteus/AutoReadOnlyCaptures.h: Extended analyzeReadOnlyCaptures() to
  handle both typed struct GEPs and byte-offset GEPs. Uses byte offset directly
  as slot index for untyped GEPs to avoid collisions.

- src/lib/JitEngineHost.cpp: Added fallback in getLambdaJitValues() to extract
  captures using byte offsets when ClosureType is unavailable. Fixed Args[0]
  dereference to get actual closure pointer (pointer-to-pointer due to ABI).

- tests/cpu/lambda_auto_readonly.cpp: Updated test to expect i8 instead of i1
  for bool captures, matching the actual IR representation on CPU.

All CPU lambda tests now pass with PROTEUS_AUTO_READONLY_CAPTURES=1:
- lambda_auto_readonly
- lambda_written_captures
- lambda_mixed_captures
- lambda_pointer_captures

Resolves: proteus-oub

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Enable PROTEUS_AUTO_READONLY_CAPTURES=1 in the CPU lambda_mixed_captures test
to match the GPU equivalent and verify auto-detection of read-only lambda captures.

Changes:
- Set PROTEUS_AUTO_READONLY_CAPTURES=1 in RUN line
- Add CHECK-DAG lines to verify auto-detected captures B (i32 20) and D (double 2.71)
- Test now validates both explicit captures (A, C) and auto-detected captures (B, D)

This ensures the CPU test properly verifies that captures B and D are auto-detected
alongside the explicit jit_variable captures A and C.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the CPU lambda_written_captures test to match the GPU equivalent
by enabling PROTEUS_AUTO_READONLY_CAPTURES=1 and adding CHECK lines to
verify auto-detection behavior:
- A (i32 10) and C (i32 30) are auto-detected as read-only
- B (i32 20) is correctly excluded because it's written in the lambda

This ensures both CPU and GPU tests verify the same auto-detection
functionality.

Fixes: proteus-5of

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Enable PROTEUS_AUTO_READONLY_CAPTURES=1 in the CPU lambda_pointer_captures
test to verify auto-detection behavior with pointer captures. This brings
the CPU test in line with the GPU equivalent.

Changes:
- Updated RUN line to use PROTEUS_AUTO_READONLY_CAPTURES=1
- Added CHECK lines to verify scalar captures (Scalar, Value) are auto-detected
- Added CHECK-NOT lines to verify pointer captures (Ptr, PtrOnly) are NOT
  auto-detected (Phase 1 limitation)

The test now verifies that:
- Scalar (i32 42) and Value (double 3.14) are auto-detected
- Ptr and PtrOnly are correctly excluded from auto-detection
- Output values remain correct (x[0]=42, x[1]=3.14)

Closes: proteus-qiw

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add documentation for the PROTEUS_AUTO_READONLY_CAPTURES environment
variable to the user configuration guide. This option enables automatic
detection of read-only lambda captures for JIT specialization, allowing
scalar captures (int, float, double, bool) that are read-only within
the lambda body to be automatically specialized without requiring
explicit jit_variable() annotation. Default value is 1 (enabled).

Resolves beads task proteus-uqm.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes four issues that caused test failures:

1. Lambda registration cache loss: registerLambda was unconditionally
   overwriting JitVariableMap on every call, clearing explicit captures.
   Now only updates map if new registration or has pending variables.

2. Floating-point formatting: traceOutAuto used %e (scientific notation)
   producing "3.140000e+00" instead of "3.14". Changed to %g for compact
   representation.

3. Boolean type representation: Test expected i1 but C++ ABI stores bool
   as 1-byte (i8). Updated test expectation to match actual IR.

4. Capture order dependency: Tests used CHECK which requires specific
   order. Changed to CHECK-DAG to allow captures in any order since
   struct layout determines ordering.

All 6 tests now pass: lambda_def, lambda_pointer_captures (CPU/GPU),
lambda_auto_readonly.HIP, lambda_def.HIP, and lambda_def.HIP.rdc.

Co-Authored-By: Claude (claude-sonnet-4.5) <noreply@anthropic.com>
@davidbeckingsale davidbeckingsale marked this pull request as ready for review February 4, 2026 03:31
github-actions[bot]

This comment was marked as spam.

github-actions[bot]

This comment was marked as spam.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/include/proteus/AutoReadOnlyCaptures.h b/include/proteus/AutoReadOnlyCaptures.h
index 02f565d..d8b40a1 100644
--- a/include/proteus/AutoReadOnlyCaptures.h
+++ b/include/proteus/AutoReadOnlyCaptures.h
@@ -16 +16 @@
-#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/DenseMap.h"
@@ -19 +19,4 @@
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DerivedTypes.h"
@@ -22 +24,0 @@
-#include "llvm/IR/Constants.h"
@@ -25,3 +26,0 @@
-#include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/DataLayout.h"
-#include "llvm/Support/raw_ostream.h"
@@ -28,0 +28 @@
+#include "llvm/Support/raw_ostream.h"
@@ -36,4 +36,4 @@ struct CaptureInfo {
-  int32_t Offset;              // Byte offset within lambda closure
-  int32_t SlotIndex;           // GEP slot index for struct access (0-based)
-  llvm::Type *CaptureType;     // LLVM type of the capture
-  bool IsReadOnly;             // Whether capture is read-only
+  int32_t Offset;          // Byte offset within lambda closure
+  int32_t SlotIndex;       // GEP slot index for struct access (0-based)
+  llvm::Type *CaptureType; // LLVM type of the capture
+  bool IsReadOnly;         // Whether capture is read-only
@@ -44,2 +44,2 @@ inline bool isSupportedScalarType(llvm::Type *Ty) {
-  if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) ||
-      Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
+  if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(32) ||
+      Ty->isIntegerTy(64))
@@ -56 +56 @@ inline bool pointerEscapes(llvm::Value *V) {
-      return true;  // Pointer stored somewhere
+      return true; // Pointer stored somewhere
@@ -58 +58 @@ inline bool pointerEscapes(llvm::Value *V) {
-      return true;  // Pointer passed to function
+      return true; // Pointer passed to function
@@ -60 +60 @@ inline bool pointerEscapes(llvm::Value *V) {
-      if (pointerEscapes(GEP))  // Recurse for derived pointers
+      if (pointerEscapes(GEP)) // Recurse for derived pointers
@@ -68 +68,2 @@ inline bool pointerEscapes(llvm::Value *V) {
-/// Merge auto-detected captures with explicit captures (explicit takes precedence)
+/// Merge auto-detected captures with explicit captures (explicit takes
+/// precedence)
@@ -173 +174,2 @@ inline llvm::SmallVector<CaptureInfo> analyzeReadOnlyCaptures(Function &F) {
-            SlotInfo[SlotIndex] = {ByteOffset, SlotIndex, CaptureType, IsReadOnly};
+            SlotInfo[SlotIndex] = {ByteOffset, SlotIndex, CaptureType,
+                                   IsReadOnly};
@@ -238,3 +240,2 @@ extractAutoDetectedCaptures(const void *LambdaClosure,
-    Result.push_back(
-        readValueFromMemory(ClosureBytes + ByteOffset, Cap.CaptureType,
-                            Cap.SlotIndex));
+    Result.push_back(readValueFromMemory(ClosureBytes + ByteOffset,
+                                         Cap.CaptureType, Cap.SlotIndex));
diff --git a/include/proteus/JitEngineDevice.h b/include/proteus/JitEngineDevice.h
index b7babff..b70b7ea 100644
--- a/include/proteus/JitEngineDevice.h
+++ b/include/proteus/JitEngineDevice.h
@@ -460 +460 @@ public:
-                                                 ExplicitValues.end());
+                                                ExplicitValues.end());
@@ -510,2 +510,2 @@ public:
-      LambdaJitValuesVec.insert(LambdaJitValuesVec.end(),
-                                MergedValues.begin(), MergedValues.end());
+      LambdaJitValuesVec.insert(LambdaJitValuesVec.end(), MergedValues.begin(),
+                                MergedValues.end());
diff --git a/include/proteus/JitInterface.h b/include/proteus/JitInterface.h
index f556ee9..017a4ce 100644
--- a/include/proteus/JitInterface.h
+++ b/include/proteus/JitInterface.h
@@ -23 +23,3 @@ extern "C" void __jit_push_variable(proteus::RuntimeConstant RC);
-extern "C" void __jit_register_lambda(const char *Symbol, const void *ClosurePtr, size_t ClosureSize);
+extern "C" void __jit_register_lambda(const char *Symbol,
+                                      const void *ClosurePtr,
+                                      size_t ClosureSize);
diff --git a/include/proteus/LambdaRegistry.h b/include/proteus/LambdaRegistry.h
index c050d15..13bb841 100644
--- a/include/proteus/LambdaRegistry.h
+++ b/include/proteus/LambdaRegistry.h
@@ -82 +82,2 @@ public:
-  inline void registerLambda(const char *LambdaType, const void *ClosurePtr = nullptr,
+  inline void registerLambda(const char *LambdaType,
+                             const void *ClosurePtr = nullptr,
@@ -88,2 +89,3 @@ public:
-    // Only update JitVariableMap if this is a new registration or if we have pending variables
-    // This prevents overwriting explicit captures when register_lambda is called multiple times
+    // Only update JitVariableMap if this is a new registration or if we have
+    // pending variables This prevents overwriting explicit captures when
+    // register_lambda is called multiple times
@@ -98 +100,2 @@ public:
-    if (Config::get().ProteusAutoReadOnlyCaptures && ClosurePtr && ClosureSize > 0) {
+    if (Config::get().ProteusAutoReadOnlyCaptures && ClosurePtr &&
+        ClosureSize > 0) {
diff --git a/src/lib/CompilerInterfaceHost.cpp b/src/lib/CompilerInterfaceHost.cpp
index 21f2e72..cb8215a 100644
--- a/src/lib/CompilerInterfaceHost.cpp
+++ b/src/lib/CompilerInterfaceHost.cpp
@@ -36 +36,2 @@ extern "C" __attribute__((used)) void
-__jit_register_lambda(const char *Symbol, const void *ClosurePtr, size_t ClosureSize) {
+__jit_register_lambda(const char *Symbol, const void *ClosurePtr,
+                      size_t ClosureSize) {
diff --git a/src/lib/JitEngineHost.cpp b/src/lib/JitEngineHost.cpp
index da97bf9..d6ec8f8 100644
--- a/src/lib/JitEngineHost.cpp
+++ b/src/lib/JitEngineHost.cpp
@@ -135,3 +135,4 @@ JitEngineHost::~JitEngineHost() {
-void JitEngineHost::specializeIR(Module &M, StringRef FnName, StringRef Suffix,
-                                 ArrayRef<RuntimeConstant> RCArray,
-                                 const SmallVector<RuntimeConstant> &LambdaJitValuesVec) {
+void JitEngineHost::specializeIR(
+    Module &M, StringRef FnName, StringRef Suffix,
+    ArrayRef<RuntimeConstant> RCArray,
+    const SmallVector<RuntimeConstant> &LambdaJitValuesVec) {
@@ -201 +202 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-                                             ExplicitValues.end());
+                                            ExplicitValues.end());
@@ -217 +218,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-        const auto *ClosureData = LR.getClosureData(OptionalMapIt.value()->first);
+        const auto *ClosureData =
+            LR.getClosureData(OptionalMapIt.value()->first);
@@ -223 +225,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-          // Args[0] contains a pointer-to-pointer to the lambda closure (due to ABI)
+          // Args[0] contains a pointer-to-pointer to the lambda closure (due to
+          // ABI)
@@ -241,3 +244,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-                AutoCaptures.push_back(
-                    readValueFromMemory(ClosureBytes + Cap.Offset, Cap.CaptureType,
-                                        Cap.SlotIndex));
+                AutoCaptures.push_back(readValueFromMemory(
+                    ClosureBytes + Cap.Offset, Cap.CaptureType, Cap.SlotIndex));
diff --git a/src/pass/ProteusPass.cpp b/src/pass/ProteusPass.cpp
index 3b28be5..0dd329d 100644
--- a/src/pass/ProteusPass.cpp
+++ b/src/pass/ProteusPass.cpp
@@ -784 +784,2 @@ private:
-    // Check if this is a lambda function (contains ::operator() in demangled name)
+    // Check if this is a lambda function (contains ::operator() in demangled
+    // name)
diff --git a/tests/cpu/lambda_auto_readonly.cpp b/tests/cpu/lambda_auto_readonly.cpp
index a3d84e2..99ea679 100644
--- a/tests/cpu/lambda_auto_readonly.cpp
+++ b/tests/cpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-to_readonly.cpp b/tests/cpu/lambda_auto_readonly.cpp
index a3d84e2..99ea679 100644
--- a/tests/cp+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17 +18 @@ int main() {
-a679 100644
--- a/tests/cpu/lambda_auto_readonly.cpp
+++ b/te+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_mixed_captures.cpp b/tests/cpu/lambda_mixed_captures.cpp
index 8a6dfe3..92c43bd 100644
--- a/tests/cpu/lambda_mixed_captures.cpp
+++ b/tests/cpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17,3 +18,3 @@ int main() {
-  auto lambda = [=, &X,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] () __attribute__((annotate("jit"))) {
+  auto lambda =
+      [ =, &X, A = proteus::jit_variable(A), C = proteus::jit_variable(C) ]()
+          __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_pointer_captures.cpp b/tests/cpu/lambda_pointer_captures.cpp
index 626c41a..9518063 100644
--- a/tests/cpu/lambda_pointer_captures.cpp
+++ b/tests/cpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_written_captures.cpp b/tests/cpu/lambda_written_captures.cpp
index e74a8a7..bf641ef 100644
--- a/tests/cpu/lambda_written_captures.cpp
+++ b/tests/cpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) mutable {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) mutable {
diff --git a/tests/gpu/lambda_auto_readonly.cpp b/tests/gpu/lambda_auto_readonly.cpp
index 877a685..cbdbd39 100644
--- a/tests/gpu/lambda_auto_readonly.cpp
+++ b/tests/gpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_mixed_captures.cpp b/tests/gpu/lambda_mixed_captures.cpp
index bb778da..556a985 100644
--- a/tests/gpu/lambda_mixed_captures.cpp
+++ b/tests/gpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
@@ -27,7 +28,6 @@ int main() {
-  auto lambda = [=,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] __device__
-      __attribute__((annotate("jit")))() {
-        X[0] = A + B;
-        X[1] = C + D;
-      };
+  auto lambda = [
+    =, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
+  ] __device__ __attribute__((annotate("jit"))) () {
+    X[0] = A + B;
+    X[1] = C + D;
+  };
diff --git a/tests/gpu/lambda_pointer_captures.cpp b/tests/gpu/lambda_pointer_captures.cpp
index b47f4e1..6847775 100644
--- a/tests/gpu/lambda_pointer_captures.cpp
+++ b/tests/gpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_written_captures.cpp b/tests/gpu/lambda_written_captures.cpp
index b4a5850..c1b4ea2 100644
--- a/tests/gpu/lambda_written_captures.cpp
+++ b/tests/gpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-itten_captures.cpp b/tests/gpu/lambda_written_captures.cpp
index b4a5850..c1b4ea2 100644
--- a/tests/gpu/lambda_written_c+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
@@ -25 +26 @@ int main() {
-  auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
+  auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

Have any feedback or feature suggestions? Share it here.


#include "proteus/CompilerInterfaceTypes.h"

#include "llvm/ADT/SmallVector.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseMap.h"

#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/DenseMap.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"

#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Constants.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Please remove the line(s)

  • 22

Comment on lines 25 to 27
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/raw_ostream.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Please remove the line(s)

  • 25
  • 26
  • 27

#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"

@@ -0,0 +1,51 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s

Comment on lines +27 to +33
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
auto lambda = [
=, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
] __device__ __attribute__((annotate("jit"))) () {
X[0] = A + B;
X[1] = C + D;
};

@@ -0,0 +1,56 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s

@@ -0,0 +1,46 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s

double *X;
gpuErrCheck(gpuMallocManaged(&X, sizeof(double) * 2));

auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/include/proteus/AutoReadOnlyCaptures.h b/include/proteus/AutoReadOnlyCaptures.h
index 02f565d..d8b40a1 100644
--- a/include/proteus/AutoReadOnlyCaptures.h
+++ b/include/proteus/AutoReadOnlyCaptures.h
@@ -16 +16 @@
-#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/DenseMap.h"
@@ -19 +19,4 @@
-#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DerivedTypes.h"
@@ -22 +24,0 @@
-#include "llvm/IR/Constants.h"
@@ -25,3 +26,0 @@
-#include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/DataLayout.h"
-#include "llvm/Support/raw_ostream.h"
@@ -28,0 +28 @@
+#include "llvm/Support/raw_ostream.h"
@@ -36,4 +36,4 @@ struct CaptureInfo {
-  int32_t Offset;              // Byte offset within lambda closure
-  int32_t SlotIndex;           // GEP slot index for struct access (0-based)
-  llvm::Type *CaptureType;     // LLVM type of the capture
-  bool IsReadOnly;             // Whether capture is read-only
+  int32_t Offset;          // Byte offset within lambda closure
+  int32_t SlotIndex;       // GEP slot index for struct access (0-based)
+  llvm::Type *CaptureType; // LLVM type of the capture
+  bool IsReadOnly;         // Whether capture is read-only
@@ -44,2 +44,2 @@ inline bool isSupportedScalarType(llvm::Type *Ty) {
-  if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) ||
-      Ty->isIntegerTy(32) || Ty->isIntegerTy(64))
+  if (Ty->isIntegerTy(1) || Ty->isIntegerTy(8) || Ty->isIntegerTy(32) ||
+      Ty->isIntegerTy(64))
@@ -56 +56 @@ inline bool pointerEscapes(llvm::Value *V) {
-      return true;  // Pointer stored somewhere
+      return true; // Pointer stored somewhere
@@ -58 +58 @@ inline bool pointerEscapes(llvm::Value *V) {
-      return true;  // Pointer passed to function
+      return true; // Pointer passed to function
@@ -60 +60 @@ inline bool pointerEscapes(llvm::Value *V) {
-      if (pointerEscapes(GEP))  // Recurse for derived pointers
+      if (pointerEscapes(GEP)) // Recurse for derived pointers
@@ -68 +68,2 @@ inline bool pointerEscapes(llvm::Value *V) {
-/// Merge auto-detected captures with explicit captures (explicit takes precedence)
+/// Merge auto-detected captures with explicit captures (explicit takes
+/// precedence)
@@ -173 +174,2 @@ inline llvm::SmallVector<CaptureInfo> analyzeReadOnlyCaptures(Function &F) {
-            SlotInfo[SlotIndex] = {ByteOffset, SlotIndex, CaptureType, IsReadOnly};
+            SlotInfo[SlotIndex] = {ByteOffset, SlotIndex, CaptureType,
+                                   IsReadOnly};
@@ -238,3 +240,2 @@ extractAutoDetectedCaptures(const void *LambdaClosure,
-    Result.push_back(
-        readValueFromMemory(ClosureBytes + ByteOffset, Cap.CaptureType,
-                            Cap.SlotIndex));
+    Result.push_back(readValueFromMemory(ClosureBytes + ByteOffset,
+                                         Cap.CaptureType, Cap.SlotIndex));
diff --git a/include/proteus/JitEngineDevice.h b/include/proteus/JitEngineDevice.h
index aff7e76..c92e21d 100644
--- a/include/proteus/JitEngineDevice.h
+++ b/include/proteus/JitEngineDevice.h
@@ -459 +459 @@ public:
-                                                 ExplicitValues.end());
+                                                ExplicitValues.end());
@@ -509,2 +509,2 @@ public:
-      LambdaJitValuesVec.insert(LambdaJitValuesVec.end(),
-                                MergedValues.begin(), MergedValues.end());
+      LambdaJitValuesVec.insert(LambdaJitValuesVec.end(), MergedValues.begin(),
+                                MergedValues.end());
diff --git a/include/proteus/JitInterface.h b/include/proteus/JitInterface.h
index f556ee9..017a4ce 100644
--- a/include/proteus/JitInterface.h
+++ b/include/proteus/JitInterface.h
@@ -23 +23,3 @@ extern "C" void __jit_push_variable(proteus::RuntimeConstant RC);
-extern "C" void __jit_register_lambda(const char *Symbol, const void *ClosurePtr, size_t ClosureSize);
+extern "C" void __jit_register_lambda(const char *Symbol,
+                                      const void *ClosurePtr,
+                                      size_t ClosureSize);
diff --git a/include/proteus/LambdaRegistry.h b/include/proteus/LambdaRegistry.h
index c050d15..13bb841 100644
--- a/include/proteus/LambdaRegistry.h
+++ b/include/proteus/LambdaRegistry.h
@@ -82 +82,2 @@ public:
-  inline void registerLambda(const char *LambdaType, const void *ClosurePtr = nullptr,
+  inline void registerLambda(const char *LambdaType,
+                             const void *ClosurePtr = nullptr,
@@ -88,2 +89,3 @@ public:
-    // Only update JitVariableMap if this is a new registration or if we have pending variables
-    // This prevents overwriting explicit captures when register_lambda is called multiple times
+    // Only update JitVariableMap if this is a new registration or if we have
+    // pending variables This prevents overwriting explicit captures when
+    // register_lambda is called multiple times
@@ -98 +100,2 @@ public:
-    if (Config::get().ProteusAutoReadOnlyCaptures && ClosurePtr && ClosureSize > 0) {
+    if (Config::get().ProteusAutoReadOnlyCaptures && ClosurePtr &&
+        ClosureSize > 0) {
diff --git a/src/lib/CompilerInterfaceHost.cpp b/src/lib/CompilerInterfaceHost.cpp
index 21f2e72..cb8215a 100644
--- a/src/lib/CompilerInterfaceHost.cpp
+++ b/src/lib/CompilerInterfaceHost.cpp
@@ -36 +36,2 @@ extern "C" __attribute__((used)) void
-__jit_register_lambda(const char *Symbol, const void *ClosurePtr, size_t ClosureSize) {
+__jit_register_lambda(const char *Symbol, const void *ClosurePtr,
+                      size_t ClosureSize) {
diff --git a/src/lib/JitEngineHost.cpp b/src/lib/JitEngineHost.cpp
index da97bf9..d6ec8f8 100644
--- a/src/lib/JitEngineHost.cpp
+++ b/src/lib/JitEngineHost.cpp
@@ -135,3 +135,4 @@ JitEngineHost::~JitEngineHost() {
-void JitEngineHost::specializeIR(Module &M, StringRef FnName, StringRef Suffix,
-                                 ArrayRef<RuntimeConstant> RCArray,
-                                 const SmallVector<RuntimeConstant> &LambdaJitValuesVec) {
+void JitEngineHost::specializeIR(
+    Module &M, StringRef FnName, StringRef Suffix,
+    ArrayRef<RuntimeConstant> RCArray,
+    const SmallVector<RuntimeConstant> &LambdaJitValuesVec) {
@@ -201 +202 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-                                             ExplicitValues.end());
+                                            ExplicitValues.end());
@@ -217 +218,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-        const auto *ClosureData = LR.getClosureData(OptionalMapIt.value()->first);
+        const auto *ClosureData =
+            LR.getClosureData(OptionalMapIt.value()->first);
@@ -223 +225,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-          // Args[0] contains a pointer-to-pointer to the lambda closure (due to ABI)
+          // Args[0] contains a pointer-to-pointer to the lambda closure (due to
+          // ABI)
@@ -241,3 +244,2 @@ void getLambdaJitValues(Module &M, StringRef FnName, void **Args,
-                AutoCaptures.push_back(
-                    readValueFromMemory(ClosureBytes + Cap.Offset, Cap.CaptureType,
-                                        Cap.SlotIndex));
+                AutoCaptures.push_back(readValueFromMemory(
+                    ClosureBytes + Cap.Offset, Cap.CaptureType, Cap.SlotIndex));
diff --git a/src/pass/ProteusPass.cpp b/src/pass/ProteusPass.cpp
index 3b28be5..0dd329d 100644
--- a/src/pass/ProteusPass.cpp
+++ b/src/pass/ProteusPass.cpp
@@ -784 +784,2 @@ private:
-    // Check if this is a lambda function (contains ::operator() in demangled name)
+    // Check if this is a lambda function (contains ::operator() in demangled
+    // name)
diff --git a/tests/cpu/lambda_auto_readonly.cpp b/tests/cpu/lambda_auto_readonly.cpp
index a3d84e2..99ea679 100644
--- a/tests/cpu/lambda_auto_readonly.cpp
+++ b/tests/cpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17 +18 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_mixed_captures.cpp b/tests/cpu/lambda_mixed_captures.cpp
index 8a6dfe3..92c43bd 100644
--- a/tests/cpu/lambda_mixed_captures.cpp
+++ b/tests/cpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17,3 +18,3 @@ int main() {
-  auto lambda = [=, &X,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] () __attribute__((annotate("jit"))) {
+  auto lambda =
+      [ =, &X, A = proteus::jit_variable(A), C = proteus::jit_variable(C) ]()
+          __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_pointer_captures.cpp b/tests/cpu/lambda_pointer_captures.cpp
index 626c41a..9518063 100644
--- a/tests/cpu/lambda_pointer_captures.cpp
+++ b/tests/cpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_written_captures.cpp b/tests/cpu/lambda_written_captures.cpp
index e74a8a7..bf641ef 100644
--- a/tests/cpu/lambda_written_captures.cpp
+++ b/tests/cpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) mutable {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) mutable {
diff --git a/tests/gpu/lambda_auto_readonly.cpp b/tests/gpu/lambda_auto_readonly.cpp
index 877a685..cbdbd39 100644
--- a/tests/gpu/lambda_auto_readonly.cpp
+++ b/tests/gpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_mixed_captures.cpp b/tests/gpu/lambda_mixed_captures.cpp
index bb778da..556a985 100644
--- a/tests/gpu/lambda_mixed_captures.cpp
+++ b/tests/gpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
@@ -27,7 +28,6 @@ int main() {
-  auto lambda = [=,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] __device__
-      __attribute__((annotate("jit")))() {
-        X[0] = A + B;
-        X[1] = C + D;
-      };
+  auto lambda = [
+    =, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
+  ] __device__ __attribute__((annotate("jit"))) () {
+    X[0] = A + B;
+    X[1] = C + D;
+  };
diff --git a/tests/gpu/lambda_pointer_captures.cpp b/tests/gpu/lambda_pointer_captures.cpp
index b47f4e1..6847775 100644
--- a/tests/gpu/lambda_pointer_captures.cpp
+++ b/tests/gpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_written_captures.cpp b/tests/gpu/lambda_written_captures.cpp
index b4a5850..c1b4ea2 100644
--- a/tests/gpu/lambda_written_captures.cpp
+++ b/tests/gpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
@@ -25 +26 @@ int main() {
-  auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
+  auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

Have any feedback or feature suggestions? Share it here.


#include "proteus/CompilerInterfaceTypes.h"

#include "llvm/ADT/SmallVector.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseMap.h"

#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/DenseMap.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"

#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Constants.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Please remove the line(s)

  • 22

Comment on lines 25 to 27
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/raw_ostream.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Please remove the line(s)

  • 25
  • 26
  • 27

#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"

@@ -0,0 +1,51 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s

Comment on lines +27 to +33
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
auto lambda = [
=, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
] __device__ __attribute__((annotate("jit"))) () {
X[0] = A + B;
X[1] = C + D;
};

@@ -0,0 +1,56 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s

@@ -0,0 +1,46 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s

double *X;
gpuErrCheck(gpuMallocManaged(&X, sizeof(double) * 2));

auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Cpp-linter Review

Used clang-format v18.1.3

Click here for the full clang-format patch
diff --git a/include/proteus/Frontend/Func.h b/include/proteus/Frontend/Func.h
index 98880fc..4b8b1fc 100644
--- a/include/proteus/Frontend/Func.h
+++ b/include/proteus/Frontend/Func.h
@@ -553,3 +553 @@ void FuncBase::beginFor(Var<IterT> &IterVar, const Var<InitT> &Init,
-  {
-    createBr(Header);
-  }
+  { createBr(Header); }
@@ -580,3 +578 @@ void FuncBase::beginFor(Var<IterT> &IterVar, const Var<InitT> &Init,
-  {
-    createBr(NextBlock);
-  }
+  { createBr(NextBlock); }
@@ -600,3 +596 @@ void FuncBase::beginWhile(CondLambda &&Cond, const char *File, int Line) {
-  {
-    createBr(LoopCond);
-  }
+  { createBr(LoopCond); }
@@ -615,3 +609 @@ void FuncBase::beginWhile(CondLambda &&Cond, const char *File, int Line) {
-  {
-    createBr(NextBlock);
-  }
+  { createBr(NextBlock); }
@@ -1643,3 +1635 @@ min(const Var<T> &L, const Var<T> &R) {
-  {
-    ResultVar = L;
-  }
+  { ResultVar = L; }
@@ -1661,3 +1651 @@ max(const Var<T> &L, const Var<T> &R) {
-  {
-    ResultVar = L;
-  }
+  { ResultVar = L; }
diff --git a/include/proteus/JitInterface.h b/include/proteus/JitInterface.h
index 1b24088..017a4ce 100644
--- a/include/proteus/JitInterface.h
+++ b/include/proteus/JitInterface.h
@@ -63,3 +63,3 @@ template <typename T>
-__attribute__((noinline)) __device__
-    std::enable_if_t<std::is_trivially_copyable_v<std::remove_pointer_t<T>>,
-                     void> jit_object(T *V, size_t Size = sizeof(T)) noexcept;
+__attribute__((noinline)) __device__ std::enable_if_t<
+    std::is_trivially_copyable_v<std::remove_pointer_t<T>>, void>
+jit_object(T *V, size_t Size = sizeof(T)) noexcept;
@@ -80 +80,2 @@ __attribute__((noinline)) __device__ std::enable_if_t<
-    void> jit_object(T &V, size_t Size = sizeof(T)) noexcept;
+    void>
+jit_object(T &V, size_t Size = sizeof(T)) noexcept;
diff --git a/src/lib/Frontend/Func.cpp b/src/lib/Frontend/Func.cpp
index ab5593e..4d2f6aa 100644
--- a/src/lib/Frontend/Func.cpp
+++ b/src/lib/Frontend/Func.cpp
@@ -473,3 +473 @@ void FuncBase::beginFunction(const char *File, int Line) {
-  {
-    PImpl->IRB.CreateUnreachable();
-  }
+  { PImpl->IRB.CreateUnreachable(); }
@@ -574,3 +572 @@ void FuncBase::beginIf(const Var<bool> &CondVar, const char *File, int Line) {
-  {
-    PImpl->IRB.CreateBr(ExitBlock);
-  }
+  { PImpl->IRB.CreateBr(ExitBlock); }
@@ -579,3 +575 @@ void FuncBase::beginIf(const Var<bool> &CondVar, const char *File, int Line) {
-  {
-    PImpl->IRB.CreateBr(NextBlock);
-  }
+  { PImpl->IRB.CreateBr(NextBlock); }
diff --git a/tests/cpu/lambda_auto_readonly.cpp b/tests/cpu/lambda_auto_readonly.cpp
index a3d84e2..99ea679 100644
--- a/tests/cpu/lambda_auto_readonly.cpp
+++ b/tests/cpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17 +18 @@ int main() {
-UTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_mixed_captures.cpp b/tests/cpu/lambda_mixed_captures.cpp
index 8a6dfe3..92c43bd 100644
--- a/tests/cpu/lambda_mixed_captures.cpp
+++ b/tests/cpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -17,3 +18,3 @@ int main() {
-  auto lambda = [=, &X,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] () __attribute__((annotate("jit"))) {
+  auto lambda =
+      [ =, &X, A = proteus::jit_variable(A), C = proteus::jit_variable(C) ]()
+          __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_pointer_captures.cpp b/tests/cpu/lambda_pointer_captures.cpp
index 626c41a..9518063 100644
--- a/tests/cpu/lambda_pointer_captures.cpp
+++ b/tests/cpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) {
diff --git a/tests/cpu/lambda_written_captures.cpp b/tests/cpu/lambda_written_captures.cpp
index e74a8a7..bf641ef 100644
--- a/tests/cpu/lambda_written_captures.cpp
+++ b/tests/cpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/%exe 2>&1
+// | %FILECHECK %s
@@ -16 +17 @@ int main() {
-  auto lambda = [=, &X]() __attribute__((annotate("jit"))) mutable {
+  auto lambda = [ =, &X ]() __attribute__((annotate("jit"))) mutable {
diff --git a/tests/gpu/lambda_auto_readonly.cpp b/tests/gpu/lambda_auto_readonly.cpp
index 877a685..cbdbd39 100644
--- a/tests/gpu/lambda_auto_readonly.cpp
+++ b/tests/gpu/lambda_auto_readonly.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_auto_readonly.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_mixed_captures.cpp b/tests/gpu/lambda_mixed_captures.cpp
index bb778da..556a985 100644
--- a/tests/gpu/lambda_mixed_captures.cpp
+++ b/tests/gpu/lambda_mixed_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
@@ -27,7 +28,6 @@ int main() {
-  auto lambda = [=,
-                 A = proteus::jit_variable(A),
-                 C = proteus::jit_variable(C)] __device__
-      __attribute__((annot�������� ;��i���0-
;��������������������-�       X[1] = C + D;
-      };
+  auto lambda = [
+    =, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
+  ] __device__ __attribute__((annotate("jit"))) () {
+    X[0] = A + B;
+    X[1] = C + D;
+  };
diff --git a/tests/gpu/lambda_pointer_captures.cpp b/tests/gpu/lambda_pointer_captures.cpp
index b47f4e1..6847775 100644
--- a/tests/gpu/lambda_pointer_captures.cpp
+++ b/tests/gpu/lambda_pointer_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
diff --git a/tests/gpu/lambda_written_captures.cpp b/tests/gpu/lambda_written_captures.cpp
index b4a5850..c1b4ea2 100644
--- a/tests/gpu/lambda_written_captures.cpp
+++ b/tests/gpu/lambda_written_captures.cpp
@@ -1 +1,2 @@
-// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
+// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
+// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
@@ -25 +26 @@ int main() {
-  auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
+  auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

Have any feedback or feature suggestions? Share it here.

Comment on lines +553 to +555
{
createBr(Header);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
{
createBr(Header);
}
{ createBr(Header); }

Comment on lines +580 to +582
{
createBr(NextBlock);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
{
createBr(NextBlock);
}
{ createBr(NextBlock); }

Comment on lines +600 to +602
{
createBr(LoopCond);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
{
createBr(LoopCond);
}
{ createBr(LoopCond); }

Comment on lines +615 to +617
{
createBr(NextBlock);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
{
createBr(NextBlock);
}
{ createBr(NextBlock); }

Comment on lines +1643 to +1645
{
ResultVar = L;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
{
ResultVar = L;
}
{ ResultVar = L; }

@@ -0,0 +1,51 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_mixed_captures.%ext 2>&1 | %FILECHECK %s

Comment on lines +27 to +33
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=,
A = proteus::jit_variable(A),
C = proteus::jit_variable(C)] __device__
__attribute__((annotate("jit")))() {
X[0] = A + B;
X[1] = C + D;
};
auto lambda = [
=, A = proteus::jit_variable(A), C = proteus::jit_variable(C)
] __device__ __attribute__((annotate("jit"))) () {
X[0] = A + B;
X[1] = C + D;
};

@@ -0,0 +1,56 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_pointer_captures.%ext 2>&1 | %FILECHECK %s

@@ -0,0 +1,46 @@
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1 %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s
// RUN: PROTEUS_AUTO_READONLY_CAPTURES=1 PROTEUS_TRACE_OUTPUT=1
// %build/lambda_written_captures.%ext 2>&1 | %FILECHECK %s

double *X;
gpuErrCheck(gpuMallocManaged(&X, sizeof(double) * 2));

auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
Copy link
Contributor

Choose a reason for hiding this comment

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

clang-format suggestion

Suggested change
auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
auto lambda = [=] __device__ __attribute__((annotate("jit"))) () mutable {

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v18.1.3) reports: 11 file(s) not formatted
  • include/proteus/Frontend/Func.h
  • include/proteus/JitInterface.h
  • src/lib/Frontend/Func.cpp
  • tests/cpu/lambda_auto_readonly.cpp
  • tests/cpu/lambda_mixed_captures.cpp
  • tests/cpu/lambda_pointer_captures.cpp
  • tests/cpu/lambda_written_captures.cpp
  • tests/gpu/lambda_auto_readonly.cpp
  • tests/gpu/lambda_mixed_captures.cpp
  • tests/gpu/lambda_pointer_captures.cpp
  • tests/gpu/lambda_written_captures.cpp
clang-tidy (v18.1.3) reports: 11 concern(s)
  • src/lib/CompilerInterfaceHost.cpp:36:1: warning: [readability-identifier-naming]

    invalid case style for function '__jit_register_lambda'

       36 | __jit_register_lambda(const char *Symbol, const void *ClosurePtr,
          | ^~~~~~~~~~~~~~~~~~~~~
          | jitRegisterLambda
  • tests/cpu/lambda_auto_readonly.cpp:17:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       17 |   auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
          |        ^~~~~~
          |        Lambda
       18 |     X[0] = A;
       19 |     X[1] = B;
       20 |     X[2] = C;
       21 |     X[3] = D ? 1.0 : 0.0;
       22 |   };
       23 | 
       24 |   proteus::register_lambda(lambda);
          |                            ~~~~~~
          |                            Lambda
       25 |   lambda();
          |   ~~~~~~
          |   Lambda
  • tests/cpu/lambda_mixed_captures.cpp:17:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       17 |   auto lambda = [=, &X,
          |        ^~~~~~
          |        Lambda
       18 |                  A = proteus::jit_variable(A),
       19 |                  C = proteus::jit_variable(C)] () __attribute__((annotate("jit"))) {
       20 |     X[0] = A + B;
       21 |     X[1] = C + D;
       22 |   };
       23 | 
       24 |   proteus::register_lambda(lambda);
          |                            ~~~~~~
          |                            Lambda
       25 |   lambda();
          |   ~~~~~~
          |   Lambda
  • tests/cpu/lambda_pointer_captures.cpp:16:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       16 |   auto lambda = [=, &X]() __attribute__((annotate("jit"))) {
          |        ^~~~~~
          |        Lambda
       17 |     X[0] = Scalar;
       18 |     X[1] = Value;
       19 |     (void)Ptr;
       20 |   };
       21 | 
       22 |   int *PtrOnly = &Scalar;
       23 |   auto lambda2 = [=]() __attribute__((annotate("jit"))) { (void)PtrOnly; };
       24 | 
       25 |   proteus::register_lambda(lambda);
          |                            ~~~~~~
          |                            Lambda
       26 |   proteus::register_lambda(lambda2);
       27 | 
       28 |   lambda();
          |   ~~~~~~
          |   Lambda
  • tests/cpu/lambda_pointer_captures.cpp:23:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda2'

       23 |   auto lambda2 = [=]() __attribute__((annotate("jit"))) { (void)PtrOnly; };
          |        ^~~~~~~
          |        Lambda2
       24 | 
       25 |   proteus::register_lambda(lambda);
       26 |   proteus::register_lambda(lambda2);
          |                            ~~~~~~~
          |                            Lambda2
       27 | 
       28 |   lambda();
       29 |   lambda2();
          |   ~~~~~~~
          |   Lambda2
  • tests/cpu/lambda_written_captures.cpp:16:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       16 |   auto lambda = [=, &X]() __attribute__((annotate("jit"))) mutable {
          |        ^~~~~~
          |        Lambda
       17 |     B = B + 1;
       18 |     X[0] = A + B;
       19 |     X[1] = C;
       20 |   };
       21 | 
       22 |   proteus::register_lambda(lambda);
          |                            ~~~~~~
          |                            Lambda
       23 |   lambda();
          |   ~~~~~~
          |   Lambda
  • tests/gpu/lambda_auto_readonly.cpp:27:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       27 |   auto lambda = [=] __device__ __attribute__((annotate("jit"))) () {
          |        ^~~~~~
          |        Lambda
  • tests/gpu/lambda_mixed_captures.cpp:27:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       27 |   auto lambda = [=,
          |        ^~~~~~
          |        Lambda
  • tests/gpu/lambda_pointer_captures.cpp:26:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       26 |   auto lambda = [=] __device__ __attribute__((annotate("jit"))) () {
          |        ^~~~~~
          |        Lambda
  • tests/gpu/lambda_pointer_captures.cpp:33:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda2'

       33 |   auto lambda2 = [=] __device__ __attribute__((annotate("jit"))) () {
          |        ^~~~~~~
          |        Lambda2
  • tests/gpu/lambda_written_captures.cpp:25:8: warning: [readability-identifier-naming]

    invalid case style for variable 'lambda'

       25 |   auto lambda = [=] __device__ __attribute__((annotate("jit")))() mutable {
          |        ^~~~~~
          |        Lambda

Have any feedback or feature suggestions? Share it here.

github-actions[bot]

This comment was marked as off-topic.

Copy link
Collaborator

@ggeorgakoudis ggeorgakoudis left a comment

Choose a reason for hiding this comment

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

A lot of good features and interesting.

Left quite some comments. The most important is to move the read-only analysis in the pass and some clarifications on the analysis. The rest are mostly style changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated code changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated code changes

endif()

add_library(proteus STATIC ${SOURCES})
set_target_properties(proteus PROPERTIES POSITION_INDEPENDENT_CODE ON)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Explain

# On macOS we avoid the use of the -Bsymbolic linker flag.
target_link_libraries(IRLinker
PRIVATE LLVMLinker)
PRIVATE LLVMLinker proteus)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to link with proteus?

add_test(NAME ${exe} COMMAND ${LIT} -vv -D FILECHECK=${FILECHECK} ${check_source})
# Provide an explicit %ext substitution so LIT RUN lines like
# `%build/<test>.%ext` resolve to the built executable.
add_test(NAME ${exe} COMMAND ${LIT} -vv -D EXT=${CMAKE_EXECUTABLE_SUFFIX} -D FILECHECK=${FILECHECK} -D EXE=${exe} ${check_source})
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a nice lit change for convenience, but it is unrelated. Pull it out and make a separate PR that updates all test files with this change

Comment on lines +500 to +506
}
}
}
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Avoid deep nesting. The pattern:

if(!Expected)
  continue;

should work well here

Comment on lines +262 to +267
inline SmallString<128> traceOutAuto(int Slot, Constant *C) {
SmallString<128> S;
raw_svector_ostream OS(S);
OS << "[LambdaSpec][Auto] Replacing slot " << Slot << " with " << *C << "\n";
return S;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this tracing be done in TransformLambdaSpecialization that applies the transform?

__attribute__((noinline)) __device__ std::enable_if_t<
std::is_trivially_copyable_v<std::remove_pointer_t<T>>, void>
jit_object(T *V, size_t Size = sizeof(T)) noexcept;
__attribute__((noinline)) __device__
Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated change

std::is_trivially_copyable_v<std::remove_reference_t<T>>,
void>
jit_object(T &V, size_t Size = sizeof(T)) noexcept;
void> jit_object(T &V, size_t Size = sizeof(T)) noexcept;
Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated change


LambdaJitValuesVec = OptionalMapIt.value()->getSecond();
// Get the explicit jit_variable captures
const SmallVector<RuntimeConstant> &ExplicitValues =
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code seems similar with JitEngineDevice.h. We can move to parent JitEngine if they share it.

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