This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

What's the effect of __touch()?

I'm sure this is documented, somewhere, but the searching both this site & the web is failing me.  I also checked the TMS320C674x DSP Cache User's Guide and the TMS320C6000 Optimizing Compiler v7.6 User's Guide.

On to my questions...  I have seen this used in our codebase.  Is this simply allocating a cacheline?  Does it invalidate the existing contents?  What do the parameters mean - address and size?  Does it block?  Does it have a return value?

Based on how it's used, I think the prototype looks something like this:

void __touch( void *, int );

Thanks.

  • Matt,

    Where do you find this in the TI libraries?

    Which device are you interested in?

    For what devices was your codebase written?

    I have written my own touch loops to warm the cache before doing a benchmark, but I just used a simple for-loop and wrote it in C. You want to read a single native memory element from the beginning of each cache line throughout the array you want to pull into the cache, so it is very device-dependent in terms of cache-line size.

    A quick search by me also came up empty, looking through the files on my PC. So we will need something specific to comment on. If it was written by your own team, then perhaps you can show the source or otherwise clarify how we can help. Or if it ours, your pointer may help us find it and make some comments.

    Regards,
    RandyP
  • It's a C674x DSP core. I don't know when the code was written, or by whom. I can try looking at the preprocessed output, to see in what header it's declared.  Though, I wonder if it's not a compiler builtin.

  • Matt,

    Which device is it you are using? Software packages vary greatly. The C674x core is used in multiple devices.

    Which software libraries from TI are you using, with revision?

    Which versions of CCS and the compiler are you using?

    Regards,
    RandyP
  • We're using it in a Davinci DM8127 SoC with CGT compiler 7.3.x. The OS is SYS/BIOS 6.33. We're using the RTS libraries shipped with the compiler. I'm not sure what else.
  • Matt,

    You should be able to look at the linker's .map output file and search it for __touch, if that is a label that gets included in your output .out file. From the address of the __touch symbol, you can go look for where that address falls in the .text (most likely) section and from there find out which library the object came from. The name of the library will give you an idea where it came from.

    For example, in one of my .map files I have the following lines where the first two are from the .text allocation section:

    80000000 00000180 rts6740_elf.lib : copy_decompress_rle.obj (.text:__TI_decompress_rle_core)
    80000680 00000080 : boot.obj (.text:_c_int00)

    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name

    address name
    -------- ----
    80000680 _c_int00

    Looking for _c_int00 in the symbols list shows it has the address 80000680. Going up to the .text section, that address is coincidentally the first address in the allocation for boot.obj (size 0080), and looking above it we see it comes from the rts6740_elf.lib library. This is the RunTime Support library for the 6740 for this particular build I did a couple of years ago, complied into an ELF library (differentiated from COFF).

    Regards,
    RandyP
  • I didn't find this in the .map file, but it seems to be the _touch() routine, documented in the TMS320C674x DSP Cache User's Guide (sprug82a.pdf).

    This claims to walk the address range, prefetching each contained cache line.  I wish they'd just have called it prefetch()

  • Matt,

    From how I read the Cache UG's reference to touch(), it is a concept only and the document even offers you assembly code to implement it if you want to do so.

    If you did not find touch or _touch or __touch in your map file, you are not accessing any global label by that name. So when you copy/paste the assembly code to a file in your project, you can change the name to _prefetch in the assembly file which will make the C-accessible label be touch() without the prefix _.

    Your original question was about __touch with two leading '_' characters.

    Have we or the documentation addressed all of your questions about what it does?

    Regards,
    RandyP
  • This function seems to have been disabled, in the build I was using.  That probably explains why I didn't see it in the map file.

    Thanks for your help.