llvm / llvm/offload-test-suite

Add test for `InstanceIndex`

Open
#848 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18
Forks
39
Avg merge
2d 18h
Merged PRs (30d)
40

Description

In `Test\Feature\HLSLLib` create, if applicable: (reference the HLSL headers for the types supported by the intrinsic)
- [ ] Test for 16 bit int types (`InstanceIndex.int16.test`)
- [ ] Test for Half type (`InstanceIndex.fp16.test`)
- [ ] Test for 32 bit types (`InstanceIndex.32.test`)
- [ ] Test for 64 bit int types (`InstanceIndex.int64.test`)
- [ ] Test for Double type (`InstanceIndex.fp64.test`)

A .test file should contain
- [ ] a source portion; if multiple .test files can use the same source, it can go in its own file and be referenced in the run portion of each .test file instead.
```
#--- source.hlsl

StructuredBuffer In : register(t0);
RWStructuredBuffer Out : register(u1);

[numthreads(1,1,1)]
void main() {
// A single test can test for all scalar/vector length as shown here.
Out[0] = length(In[0]); // Test float4
Out[1] = length(In[1].x); // Test float
Out[2] = length(In[1].yzw); // Test float3
Out[3] = length(In[1].yz); // Test float2
}
```
- [ ] a yaml portion; if multiple .test files can use the same YAML, it can go in its own file and be referenced in the run portion of each .test file instead.
```
//--- pipeline.yaml

---
Shaders:
- Stage: Compute
Entry: main
DispatchSize: [1, 1, 1]
Buffers:
- Name: In
Format: Float32
Stride: 16
Data: [ 4, 4, 4, 4, 3.14159, 0, 5, 12 ]
- Name: Out
Format: Float32
Stride: 4
ZeroInitSize: 12
- Name: ExpectedOut # The result we expect
Format: Float32
Stride: 4
Data: [ 8, 3.14159, 13, 5 ]
Results: # A test might have more than 1 result.
- Result: Test1
Rule: BufferFuzzy # there is also a BufferExact rule
ULPT: 1
Actual: Out
Expected: ExpectedOut
DescriptorSets:
- Resources:
- Name: In
Kind: StructuredBuffer
DirectXBinding:
Register: 0
Space: 0
VulkanBinding:
Binding: 0
- Name: Out
Kind: RWStructuredBuffer
DirectXBinding:
Register: 1
Space: 0
VulkanBinding:
Binding: 1
...
#--- end
```
- [ ] A run portion; this will be unique to each .test file.
```
# RUN: split-file %s %t
# RUN: %dxc_target -T cs_6_5 -Fo %t.o %t/source.hlsl
# RUN: %offloader %t/pipeline.yaml %t.o
```
Tests for 16 bit floating point should have a `# REQUIRES: Half`. Also add `-enable-16bit-types` to the RUN line.
Tests for 16 bit integer should have a `# REQUIRES: Int16`. Also add `-enable-16bit-types` to the RUN line.
Tests for 64 bit floating point should have a `# REQUIRES: Double`.
Tests for 64 bit integer should have a `# REQUIRES: Int64`.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Test\Feature\HLSLLib and inspect the HLSL headers for the types supported by InstanceIndex, along with nearby .test files and their RUN directives. Add the applicable type-specific tests with source, pipeline YAML, and run portions, including the listed feature requirements and compiler flags, then run the relevant test commands to verify the expected results.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
compilers, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.