getOptimalBlockElements

C++ Function Reference

1 Signature

size_t BigDataStatMeth::getOptimalBlockElements()

2 Description

Calculates optimal block size for memory-efficient matrix operations.

3 Returns

size_t Optimal number of matrix elements per processing block

4 Details

Determines optimal block element count for BigDataStatMeth algorithms based on available system memory. Provides adaptive block sizing that scales performance while maintaining compatibility across diverse hardware. Includes responsible resource usage for shared HPC environments.

5 Call Graph

Function dependencies

6 Source Code

File: inst/include/Utilities/system-utils.hppLines 102-116

inline size_t getOptimalBlockElements() {
    size_t availableMB = getAvailableMemoryMB();
    
    if (availableMB > 64000) {        // >64GB available (HPC/Server systems)
        // Responsible usage: limit to ~4GB blocks even on 1TB systems
        // Allows other users to share resources effectively
        return 500000000;             // ~4GB blocks (500M * 8 bytes)
    } else if (availableMB > 16000) { // >16GB available memory
        return 200000000;             // ~1.6GB blocks (200M * 8 bytes)
    } else if (availableMB > 8000) {  // >8GB available memory
        return 125000000;             // ~1GB blocks (125M * 8 bytes)
    } else {                          // Conservative for <8GB systems
        return 75000000;              // ~600MB blocks (75M * 8 bytes)
    }
}

7 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = getOptimalBlockElements(...);