Use of lambda causes C7x host emulation to produce different results than normal C7x execution

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Medium
    • Code Generation Tools
    • CODEGEN-15070
    • Show
      https://e2e.ti.com/e2eprivate/valeo/valeo-ep-automotive/f/valeo-emid-jacinto-forum/1584106/tda4vl-q1-tvemid-ti-c71-c-compiler-has-different-results-for-local-lambda
    • Hide
      C7000_1.4.0.LTS
      C7000_6.x.0.LTS*
      C7000_2.1.0.LTS
      C7000_5.0.0.LTS
      C7000_3.1.0.LTS
      C7000_4.1.0.LTS
      Show
      C7000_1.4.0.LTS C7000_6.x.0.LTS* C7000_2.1.0.LTS C7000_5.0.0.LTS C7000_3.1.0.LTS C7000_4.1.0.LTS
    • C7000_NEXT
    • default
    • Hide
      Replace the lambda with a regular function. Since the lambda captures nothing (empty []), you can move its body into a standalone static inline function with the same parameters and return type. The call sites remain unchanged — just call the function by name instead of through the lambda variable. This produces correct results on both C7x and host emulation.
      Show
      Replace the lambda with a regular function. Since the lambda captures nothing (empty []), you can move its body into a standalone static inline function with the same parameters and return type. The call sites remain unchanged — just call the function by name instead of through the lambda variable. This produces correct results on both C7x and host emulation.

      The attached test case has these lines ...

      uchar64 computeAbsDiff(
          const uchar64& i_Ref,
          const uchar64& i_Act,
          const cqSInt16 i_lightingOffset)
      {
          auto diff = [](
              const uchar32 i_ref,
              const uchar32 i_act,
              const cqSInt16 i_lightingOffset)
          {
              const short32 short_ref = c7x::convert<short32>(i_ref);
              const short32 short_act = c7x::convert<short32>(i_act);
              return __abs(short_act - (short_ref + short32(i_lightingOffset)));
          };
      
          auto odd  = diff(i_Ref.odd(),  i_Act.odd(),  i_lightingOffset);
          auto even = diff(i_Ref.even(), i_Act.even(), i_lightingOffset);
          return __pack_usat(odd, even);
      }
      

      The test case has surrounding code that supplies input, captures the result, then prints it. Running it under host emulation produces a different result than running on a C7x system.

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-6390 - Use of lambda causes C7x host emula...
                SYNCHRONIZED
                • Last Sync Date: