Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
CudaHelpers.ixx File Reference

CUDA utility functions for device management and kernel execution. More...

#include <cuda_runtime.h>
#include <cstdint>
#include <string>
#include <format>
#include <stdexcept>
#include <cassert>
import Cuda.Error;

Namespaces

namespace  Mila
 Mila main API namespace.
namespace  Mila::Dnn
namespace  Mila::Dnn::Compute
namespace  Mila::Dnn::Compute::Cuda

Functions

constexpr int Mila::Dnn::Compute::Cuda::ceil_div (int M, int N)
 Calculates ceiling division for kernel grid/block dimensions.
int Mila::Dnn::Compute::Cuda::checkDevice (int deviceId)
 Validates that a device ID is valid and available.
int Mila::Dnn::Compute::Cuda::findCudaDevice (int deviceId=-1, bool preferMemory=false)
 Finds the most appropriate CUDA device for computation.
int Mila::Dnn::Compute::Cuda::getBestDeviceId (bool preferMemory=false)
 Identifies the best CUDA device based on performance characteristics.
int Mila::Dnn::Compute::Cuda::getDeviceCount ()
 Gets the number of available CUDA devices.
int Mila::Dnn::Compute::Cuda::getDriverVersion ()
 Gets the installed CUDA driver version.
int Mila::Dnn::Compute::Cuda::getRuntimeVersion ()
 Gets the installed CUDA runtime version.
void Mila::Dnn::Compute::Cuda::setCurrentDevice (int device_id)
 Sets the current CUDA device with thread-local caching.

Detailed Description

CUDA utility functions for device management and kernel execution.

Provides helper functions for CUDA device discovery, selection, and kernel execution optimization. These utilities simplify working with CUDA devices and provide consistent error handling.