2 Replies Latest reply on Aug 4, 2009 8:30 AM by rexiaoyu

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

    kos
      I need that for sample instruction.

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

        • How can I get thread number in hlsl ? If i can?...
          helmutb
          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