cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

kos
Journeyman III

How can I get thread number in hlsl ? If i can?...

I need that for sample instruction.

How can I get thread number in hlsl ? If i can?...

0 Likes
2 Replies
helmutb
Journeyman III

yes you can (at least if you build amdhlsl from source provided with the 1.2.1 SDK, i haven't tried the precompiled calutAMDhlslCompiler library). Here is what i have found out:

the groupID relativeThreadID and absoluteThread ID can be accessed by

int absTid : SV_AbsThreadId,
int relTid : SV_RelThreadId,
int gid : SV_ThreadGroupId

the number of threads, the LDS size and the sharing mode you can specify with

[
NumThreads(64),
LocalDataShare(4),
LocalDataShareRel
]
void main( ... )

for reading and writing to the LDS use:

float4 ReadLds(int his_tid, int offset, bool do_neighborExch);
void WriteLds(int offset, float4 data);

and for inserting a fence_threads_lds use:

void SyncThreads(void);

I have to admit that i haven't done any tests with the compiler output yet other than sending it through the GPUShaderAnalyzer. I should also mention that you have to add some missing enums in inc/ILTables.h in order to compile amdhlsl. Still i hope this is of any help.

regards
Helmut

0 Likes

can I get the thread number in the kernel? I indeed found the csThreadInfo struct  in hlsl file.

0 Likes