| 649 | } |
| 650 | |
| 651 | void setMemoryPoolLimits(IBuilderConfig& config, BuildOptions const& build) |
| 652 | { |
| 653 | auto const roundToBytes = [](double const sizeInMB) { return static_cast<size_t>(sizeInMB * (1 << 20)); }; |
| 654 | if (build.workspace >= 0) |
| 655 | { |
| 656 | config.setMemoryPoolLimit(MemoryPoolType::kWORKSPACE, roundToBytes(build.workspace)); |
| 657 | } |
| 658 | if (build.dlaSRAM >= 0) |
| 659 | { |
| 660 | size_t const sizeInBytes = roundToBytes(build.dlaSRAM); |
| 661 | size_t sizeInPowerOf2{1}; |
| 662 | // Using 2^30 bytes as a loose upper bound to prevent the possibility of overflows and infinite loops. |
| 663 | while (sizeInPowerOf2 < 31 && (static_cast<size_t>(1) << sizeInPowerOf2) <= sizeInBytes) |
| 664 | { |
| 665 | ++sizeInPowerOf2; |
| 666 | } |
| 667 | --sizeInPowerOf2; |
| 668 | if (sizeInPowerOf2 == 30) |
| 669 | { |
| 670 | sample::gLogWarning << "User-specified DLA managed SRAM size is too large and has been clipped to 2^30 bytes. " |
| 671 | << "Please make sure that this is the intended managed SRAM size." << std::endl; |
| 672 | } |
| 673 | config.setMemoryPoolLimit(MemoryPoolType::kDLA_MANAGED_SRAM, static_cast<size_t>(1) << sizeInPowerOf2); |
| 674 | } |
| 675 | if (build.dlaLocalDRAM >= 0) |
| 676 | { |
| 677 | config.setMemoryPoolLimit(MemoryPoolType::kDLA_LOCAL_DRAM, roundToBytes(build.dlaLocalDRAM)); |
| 678 | } |
| 679 | if (build.dlaGlobalDRAM >= 0) |
| 680 | { |
| 681 | config.setMemoryPoolLimit(MemoryPoolType::kDLA_GLOBAL_DRAM, roundToBytes(build.dlaGlobalDRAM)); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | void setPreviewFeatures(IBuilderConfig& config, BuildOptions const& build) |
| 686 | { |
no test coverage detected