cuda
codegen.cuda
CUDA Adapter for TVBO
Run generated CUDA kernels using PyCUDA.
Usage
from tvbo import SimulationExperiment
exp = SimulationExperiment.from_file(“experiment.yaml”) result = exp.run(‘cuda’)
Functions
| Name | Description |
|---|---|
| compile_cuda | Compile CUDA kernel for experiment. |
| run_cuda | Run CUDA simulation for experiment. |
| save_cuda | Save CUDA source to file. |
compile_cuda
codegen.cuda.compile_cuda(experiment)Compile CUDA kernel for experiment.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiment | SimulationExperiment | SimulationExperiment instance | required |
Returns
| Name | Type | Description |
|---|---|---|
| Tuple[Any, Any] | Tuple of (module, kernel_func) |
run_cuda
codegen.cuda.run_cuda(
experiment,
n_steps=None,
dt=None,
n_work_items=1,
global_speed=1.0,
global_coupling=0.1,
buffer_length=None,
swept_params=None,
)Run CUDA simulation for experiment.
All configuration comes from experiment metadata.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiment | SimulationExperiment | SimulationExperiment instance | required |
| n_steps | Optional[int] | Number of integration steps (default from experiment.integration) | None |
| dt | Optional[float] | Integration time step in ms (default from experiment.integration) | None |
| n_work_items | int | Number of parallel parameter configurations | 1 |
| global_speed | float | Conduction speed (m/s) | 1.0 |
| global_coupling | float | Global coupling strength | 0.1 |
| buffer_length | Optional[int] | History buffer length (auto-calculated if None) | None |
| swept_params | Optional[Dict[str, np.ndarray]] | Dict mapping param names to arrays of values per work item | None |
Returns
| Name | Type | Description |
|---|---|---|
| Dict[str, np.ndarray] | Dict with ‘tavg’, ‘n_node’, ‘n_steps’, ‘dt’ |
save_cuda
codegen.cuda.save_cuda(experiment, path)Save CUDA source to file.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiment | SimulationExperiment | SimulationExperiment instance | required |
| path | str | Output file path (.cu) | required |
Returns
| Name | Type | Description |
|---|---|---|
| str | Path to saved file |