You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/03 21:55:32 UTC

[GitHub] [tvm] apivovarov commented on pull request #10882: [LLVM] Support CodeGenBlob for large >2GB models

apivovarov commented on PR #10882:
URL: https://github.com/apache/tvm/pull/10882#issuecomment-1086957088

   GCC has the following [x86-Options](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html) related to 2GB issue
   ```
   -mlarge-data-threshold=threshold
   When -mcmodel=medium is specified, data objects larger than threshold are placed in the large data section. This value must be the same across all objects linked into the binary, and defaults to 65535.
   
   -mcmodel=medium
   Generate code for the medium model: the program is linked in the lower 2 GB of the address space. Small symbols are also placed there. Symbols with sizes larger than -mlarge-data-threshold are put into large data or BSS sections and can be located above 2GB. Programs can be statically or dynamically linked.
   ```
   I checked the difference in object (.o) and asm (.s) files generated by gcc. The diff is in the section name for Read-Only Data. - mcmodel small uses `.rodata` and mcmodel medium uses `.lrodata` for const pre-defined data large than 64K.
   
   LLVM/clang also has `-mcmodel` param but it does not have `-mlarge-data-threshold` param.
   I tried to use `-mcmodel=medium` parameter with llvm/clang on x86_64 platfor - the generated object, asm and llvm files are the same for `-mcmodel=small` and `-mcmodel=medium`.
   
   LLVM/clang mostly use `mcmodel` parameter on RISC-V and XCore architectures.
   `mcmodel` parameter is ignored on X86 platform.
   
   The workaround for clang and LLVM x86 is to explicitly put section name for the large const pre-defined arrays:
   
   C/C++:
   ```
   __attribute__((section(".lrodata")))
   extern const long long int B100[131072];
   ```
   
   LLVM API:
   ```
   auto* B100 = new llvm::GlobalVariable(...)
   B100->setSection(".lrodata");
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org