Skip to content

Commit 730434c

Browse files
authored
Kernel fix (#4)
* set raw buffer in kernel * set raw buffer in kernel
1 parent 40c3eec commit 730434c

File tree

6 files changed

+103
-6
lines changed

6 files changed

+103
-6
lines changed

.beads/.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ daemon.lock
1010
daemon.log
1111
daemon.pid
1212
bd.sock
13+
sync-state.json
1314

1415
# Local version tracking (prevents upgrade notification spam after git ops)
1516
.local_version
@@ -26,7 +27,8 @@ beads.left.meta.json
2627
beads.right.jsonl
2728
beads.right.meta.json
2829

29-
# Keep JSONL exports and config (source of truth for git)
30-
!issues.jsonl
31-
!metadata.json
32-
!config.json
30+
# NOTE: Do NOT add negation patterns (e.g., !issues.jsonl) here.
31+
# They would override fork protection in .git/info/exclude, allowing
32+
# contributors to accidentally commit upstream issue databases.
33+
# The JSONL files (issues.jsonl, interactions.jsonl) and config files
34+
# are tracked by git by default since no pattern above ignores them.

.beads/interactions.jsonl

Whitespace-only changes.

.beads/issues.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
{"id":"gpu-support-ilr","title":"Extract OpenCLBuffer implementation","description":"Extract OpenCLBuffer from ART.\n\n## Source\n`/Users/hal.hildebrand/git/ART/art-modules/art-cortical/src/main/java/com/hellblazer/art/cortical/gpu/memory/OpenCLBuffer.java`\n\n## Target\n`resource/src/main/java/com/hellblazer/luciferase/resource/compute/memory/OpenCLBuffer.java`\n\n## Changes Required\n- Update package declaration\n- Update GPUBuffer import\n- CLBufferHandle.translateError() import unchanged (already in resource module)\n\n## Key Features\n- Float buffer abstraction\n- upload(FloatBuffer) / upload(float[])\n- download(FloatBuffer) / download(float[])\n- Protected constructor for subclasses (CLBufferAdapter pattern)\n- Size validation on transfers\n\n## Future Enhancement (Phase 5)\nConsider refactoring to wrap CLBufferHandle internally for RAII benefits\n\nContext: Parent feature gpu-support-5wc","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-28T17:06:16.180484-08:00","updated_at":"2025-12-28T19:52:42.541562-08:00","closed_at":"2025-12-28T19:52:42.541562-08:00","close_reason":"OpenCLBuffer tests fixed - 10 tests pass with simplified test pattern","dependencies":[{"issue_id":"gpu-support-ilr","depends_on_id":"gpu-support-gij","type":"blocks","created_at":"2025-12-28T17:06:31.264386-08:00","created_by":"daemon"}]}
1313
{"id":"gpu-support-ipz","title":"Phase 1 Unit Tests","description":"Create unit tests for Phase 1 components.\n\n## Tests Required\n1. GPUBufferTest - Interface contract verification (mock implementation)\n2. ComputeKernelTest - Interface contract, exception types\n3. GPUBackendTest - Enum values, availability checks\n4. BackendSelectorTest - Selection logic, CI detection, env vars\n5. GPUErrorClassifierTest - Error classification logic\n\n## Test Patterns\n- Use Mockito for interface testing\n- Test error classification with sample exception messages\n- Test CI environment detection with env var mocking\n\n## Acceptance Criteria\n- [ ] All tests pass\n- [ ] Coverage \u003e 80% for classifier logic\n\nContext: Parent feature gpu-support-6e9","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-28T17:05:42.229259-08:00","updated_at":"2025-12-28T18:11:02.203471-08:00","closed_at":"2025-12-28T18:11:02.203471-08:00","close_reason":"Closed","dependencies":[{"issue_id":"gpu-support-ipz","depends_on_id":"gpu-support-kdp","type":"blocks","created_at":"2025-12-28T17:05:49.00115-08:00","created_by":"daemon"},{"issue_id":"gpu-support-ipz","depends_on_id":"gpu-support-cbr","type":"blocks","created_at":"2025-12-28T17:05:49.077511-08:00","created_by":"daemon"},{"issue_id":"gpu-support-ipz","depends_on_id":"gpu-support-e63","type":"blocks","created_at":"2025-12-28T17:10:14.155949-08:00","created_by":"daemon"},{"issue_id":"gpu-support-ipz","depends_on_id":"gpu-support-ad2","type":"blocks","created_at":"2025-12-28T17:10:14.229753-08:00","created_by":"daemon"},{"issue_id":"gpu-support-ipz","depends_on_id":"gpu-support-9go","type":"blocks","created_at":"2025-12-28T17:10:14.30489-08:00","created_by":"daemon"}]}
1414
{"id":"gpu-support-kdp","title":"Extract GPUErrorClassifier","description":"Extract GPUErrorClassifier from ART.\n\n## Source\n`/Users/hal.hildebrand/git/ART/art-modules/art-cortical/src/main/java/com/hellblazer/art/cortical/gpu/compute/GPUErrorClassifier.java`\n\n## Target\n`resource/src/main/java/com/hellblazer/luciferase/resource/compute/GPUErrorClassifier.java`\n\n## Changes Required\n- Update package declaration\n- Update ComputeKernel.KernelCompilationException import\n- Update ComputeKernel.KernelExecutionException import\n\n## Key Features to Preserve\n- Programming error detection (fail fast)\n- Recoverable error detection (allow CPU fallback)\n- OpenCL error code extraction from messages\n- Error code to name translation\n\nContext: Parent feature gpu-support-6e9","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-28T17:03:23.717012-08:00","updated_at":"2025-12-28T18:10:23.076314-08:00","closed_at":"2025-12-28T18:10:23.076314-08:00","close_reason":"Closed","dependencies":[{"issue_id":"gpu-support-kdp","depends_on_id":"gpu-support-ad2","type":"blocks","created_at":"2025-12-28T17:05:48.769925-08:00","created_by":"daemon"}]}
15-
{"id":"gpu-support-trf","title":"Phase 4: ART Migration","description":"Migrate ART to use gpu-support compute infrastructure.\n\n## Tasks\n1. Update ART pom.xml to depend on gpu-support 1.0.5+\n2. Update ART imports from art.cortical.gpu to luciferase.resource.compute\n3. Remove extracted code from ART (compute/, memory/, kernels/ packages)\n4. Run full ART test suite to validate\n\n## Risk Mitigation\n- Keep ART working on separate branch until validated\n- Run performance comparison before/after\n\n## Acceptance Criteria\n- [ ] ART builds successfully with new dependency\n- [ ] All ART GPU tests pass\n- [ ] No duplicate code remains in ART\n- [ ] Performance within 5% of original\n\nContext: Depends on gpu-support-0y1 (Phase 3)","status":"open","priority":2,"issue_type":"feature","created_at":"2025-12-28T17:02:02.780414-08:00","updated_at":"2025-12-28T17:02:02.780414-08:00","dependencies":[{"issue_id":"gpu-support-trf","depends_on_id":"gpu-support-0y1","type":"blocks","created_at":"2025-12-28T17:02:43.652183-08:00","created_by":"daemon"}]}
15+
{"id":"gpu-support-trf","title":"Phase 4: ART Migration","description":"Migrate ART to use gpu-support compute infrastructure.\n\n## Tasks\n1. Update ART pom.xml to depend on gpu-support 1.0.5+\n2. Update ART imports from art.cortical.gpu to luciferase.resource.compute\n3. Remove extracted code from ART (compute/, memory/, kernels/ packages)\n4. Run full ART test suite to validate\n\n## Risk Mitigation\n- Keep ART working on separate branch until validated\n- Run performance comparison before/after\n\n## Acceptance Criteria\n- [ ] ART builds successfully with new dependency\n- [ ] All ART GPU tests pass\n- [ ] No duplicate code remains in ART\n- [ ] Performance within 5% of original\n\nContext: Depends on gpu-support-0y1 (Phase 3)","status":"closed","priority":2,"issue_type":"feature","created_at":"2025-12-28T17:02:02.780414-08:00","updated_at":"2025-12-31T10:05:25.24913-08:00","closed_at":"2025-12-29T02:01:55.866187-08:00","dependencies":[{"issue_id":"gpu-support-trf","depends_on_id":"gpu-support-0y1","type":"blocks","created_at":"2025-12-28T17:02:43.652183-08:00","created_by":"daemon"}]}

AGENTS.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,29 @@ if (!compute.isGPUAvailable()) return;
192192
./mvnw test -pl resource # Test compute module
193193
./mvnw test -Dtest=ComputeServiceTest # Specific test
194194
```
195+
196+
## Landing the Plane (Session Completion)
197+
198+
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
199+
200+
**MANDATORY WORKFLOW:**
201+
202+
1. **File issues for remaining work** - Create issues for anything that needs follow-up
203+
2. **Run quality gates** (if code changed) - Tests, linters, builds
204+
3. **Update issue status** - Close finished work, update in-progress items
205+
4. **PUSH TO REMOTE** - This is MANDATORY:
206+
```bash
207+
git pull --rebase
208+
bd sync
209+
git push
210+
git status # MUST show "up to date with origin"
211+
```
212+
5. **Clean up** - Clear stashes, prune remote branches
213+
6. **Verify** - All changes committed AND pushed
214+
7. **Hand off** - Provide context for next session
215+
216+
**CRITICAL RULES:**
217+
- Work is NOT complete until `git push` succeeds
218+
- NEVER stop before pushing - that leaves work stranded locally
219+
- NEVER say "ready to push when you are" - YOU must push
220+
- If push fails, resolve and retry until it succeeds

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
<plugin>
196196
<groupId>org.apache.maven.plugins</groupId>
197197
<artifactId>maven-surefire-plugin</artifactId>
198-
<version>3.0.0-M9</version>
199198
</plugin>
200199
<plugin>
201200
<groupId>org.apache.maven.plugins</groupId>
@@ -207,6 +206,19 @@
207206
<version>3.1.1</version>
208207
</plugin>
209208
</plugins>
209+
<pluginManagement>
210+
<plugins>
211+
<plugin>
212+
<groupId>org.apache.maven.plugins</groupId>
213+
<artifactId>maven-surefire-plugin</artifactId>
214+
<version>3.0.0-M9</version>
215+
<configuration>
216+
<useModulePath>false</useModulePath>
217+
<argLine>-Djava.awt.headless=true</argLine>
218+
</configuration>
219+
</plugin>
220+
</plugins>
221+
</pluginManagement>
210222
</build>
211223

212224

resource/src/main/java/com/hellblazer/luciferase/resource/compute/opencl/OpenCLKernel.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,63 @@ public void setLocalMemoryArg(int index, int sizeInBytes) {
212212
}
213213
}
214214

215+
/**
216+
* Set a raw OpenCL memory object as a kernel argument.
217+
*
218+
* <p>This method allows setting raw cl_mem handles directly, useful when
219+
* working with buffers created outside the GPUBuffer abstraction (e.g.,
220+
* ByteBuffer uploads via clCreateBuffer).
221+
*
222+
* @param index Argument index
223+
* @param clMem Raw OpenCL memory object handle (cl_mem)
224+
* @throws IllegalStateException if kernel is closed or not compiled
225+
*/
226+
public void setRawBufferArg(int index, long clMem) {
227+
checkNotClosed();
228+
checkCompiled();
229+
230+
try {
231+
checkCLError(
232+
clSetKernelArg1p(kernel, index, clMem),
233+
"Failed to set raw buffer argument " + index
234+
);
235+
} catch (KernelCompilationException e) {
236+
throw new RuntimeException(e); // Convert to unchecked for setter
237+
}
238+
}
239+
240+
/**
241+
* Set a float3 vector argument.
242+
*
243+
* <p>Passes a 3-component float vector to the kernel. Useful for
244+
* scene bounds, positions, directions, etc.
245+
*
246+
* @param index Argument index
247+
* @param x X component
248+
* @param y Y component
249+
* @param z Z component
250+
* @throws IllegalStateException if kernel is closed or not compiled
251+
*/
252+
public void setFloat3Arg(int index, float x, float y, float z) {
253+
checkNotClosed();
254+
checkCompiled();
255+
256+
try (var stack = stackPush()) {
257+
var buffer = stack.mallocFloat(3);
258+
buffer.put(0, x);
259+
buffer.put(1, y);
260+
buffer.put(2, z);
261+
try {
262+
checkCLError(
263+
clSetKernelArg(kernel, index, buffer),
264+
"Failed to set float3 argument " + index
265+
);
266+
} catch (KernelCompilationException e) {
267+
throw new RuntimeException(e); // Convert to unchecked for setter
268+
}
269+
}
270+
}
271+
215272
@Override
216273
public void execute(int globalWorkSize) throws KernelExecutionException {
217274
execute(globalWorkSize, 1, 1);

0 commit comments

Comments
 (0)