LCOV - code coverage report
Current view: top level - solvers/gpu - solver_gpu_stub.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 21.0 % 81 17
Test Date: 2026-03-04 10:22:18 Functions: 14.3 % 14 2

            Line data    Source code
       1              : /**
       2              :  * GPU NSSolver Stub Implementation (No CUDA)
       3              :  *
       4              :  * This file provides stub implementations when CUDA is not available.
       5              :  * All functions report that GPU is not available and return appropriate errors.
       6              :  */
       7              : 
       8              : #include "cfd/core/cfd_status.h"
       9              : #include "cfd/core/grid.h"
      10              : #include "cfd/core/gpu_device.h"
      11              : #include "cfd/solvers/navier_stokes_solver.h"
      12              : #include <stdio.h>
      13              : #include <string.h>
      14              : 
      15            3 : gpu_config_t gpu_config_default(void) {
      16            3 :     gpu_config_t config;
      17            3 :     memset(&config, 0, sizeof(gpu_config_t));
      18            3 :     config.enable_gpu = 0;  // Disabled by default when CUDA not available
      19            3 :     config.min_grid_size = 10000;
      20            3 :     config.min_steps = 10;
      21            3 :     config.block_size_x = 16;
      22            3 :     config.block_size_y = 16;
      23            3 :     config.poisson_max_iter = 1000;
      24            3 :     config.poisson_tolerance = 1e-6;
      25            3 :     config.persistent_memory = 1;
      26            3 :     config.async_transfers = 1;
      27            3 :     config.sync_after_kernel = 0;
      28            3 :     config.verbose = 0;
      29            3 :     return config;
      30              : }
      31              : 
      32           42 : int gpu_is_available(void) {
      33           42 :     return 0;  // No CUDA available
      34              : }
      35              : 
      36            0 : int gpu_get_device_info(gpu_device_info_t* info, int max_devices) {
      37            0 :     (void)info;
      38            0 :     (void)max_devices;
      39            0 :     return 0;  // No devices
      40              : }
      41              : 
      42            0 : cfd_status_t gpu_select_device(int device_id) {
      43            0 :     (void)device_id;
      44            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "CUDA not available (compiled without CUDA support)");
      45            0 :     return CFD_ERROR_UNSUPPORTED;
      46              : }
      47              : 
      48            0 : int gpu_should_use(const gpu_config_t* config, size_t nx, size_t ny, size_t nz, int num_steps) {
      49            0 :     (void)config;
      50            0 :     (void)nx;
      51            0 :     (void)ny;
      52            0 :     (void)nz;
      53            0 :     (void)num_steps;
      54            0 :     return 0;  // Never use GPU (not available)
      55              : }
      56              : 
      57            0 : gpu_solver_context_t* gpu_solver_create(size_t nx, size_t ny, size_t nz, const gpu_config_t* config) {
      58            0 :     (void)nx;
      59            0 :     (void)ny;
      60            0 :     (void)nz;
      61            0 :     (void)config;
      62            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "CUDA not available (compiled without CUDA support)");
      63            0 :     return NULL;
      64              : }
      65              : 
      66            0 : void gpu_solver_destroy(gpu_solver_context_t* ctx) {
      67            0 :     (void)ctx;
      68              :     // Nothing to do
      69            0 : }
      70              : 
      71            0 : cfd_status_t gpu_solver_upload(gpu_solver_context_t* ctx, const flow_field* field) {
      72            0 :     (void)ctx;
      73            0 :     (void)field;
      74            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "CUDA not available (compiled without CUDA support)");
      75            0 :     return CFD_ERROR_UNSUPPORTED;
      76              : }
      77              : 
      78            0 : cfd_status_t gpu_solver_download(gpu_solver_context_t* ctx, flow_field* field) {
      79            0 :     (void)ctx;
      80            0 :     (void)field;
      81            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "CUDA not available (compiled without CUDA support)");
      82            0 :     return CFD_ERROR_UNSUPPORTED;
      83              : }
      84              : 
      85            0 : cfd_status_t gpu_solver_step(gpu_solver_context_t* ctx, const grid* grid, const ns_solver_params_t* params,
      86              :                              gpu_solver_stats_t* stats) {
      87            0 :     (void)ctx;
      88            0 :     (void)grid;
      89            0 :     (void)params;
      90            0 :     (void)stats;
      91            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "CUDA not available (compiled without CUDA support)");
      92            0 :     return CFD_ERROR_UNSUPPORTED;
      93              : }
      94              : 
      95            0 : gpu_solver_stats_t gpu_solver_get_stats(const gpu_solver_context_t* ctx) {
      96            0 :     (void)ctx;
      97            0 :     gpu_solver_stats_t stats;
      98            0 :     memset(&stats, 0, sizeof(gpu_solver_stats_t));
      99            0 :     return stats;
     100              : }
     101              : 
     102            0 : void gpu_solver_reset_stats(gpu_solver_context_t* ctx) {
     103            0 :     (void)ctx;
     104            0 : }
     105              : 
     106            0 : cfd_status_t solve_navier_stokes_gpu(flow_field* field, const grid* grid,
     107              :                                      const ns_solver_params_t* params, const gpu_config_t* config) {
     108            0 :     (void)field;
     109            0 :     (void)grid;
     110            0 :     (void)params;
     111            0 :     (void)config;
     112              : 
     113            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU solver: CUDA not available (compiled without CUDA support)");
     114            0 :     return CFD_ERROR_UNSUPPORTED;
     115              : }
     116              : 
     117            0 : cfd_status_t solve_projection_method_gpu(flow_field* field, const grid* grid,
     118              :                                          const ns_solver_params_t* params, const gpu_config_t* config) {
     119            0 :     (void)field;
     120            0 :     (void)grid;
     121            0 :     (void)params;
     122            0 :     (void)config;
     123              : 
     124            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU projection solver: CUDA not available (compiled without CUDA support)");
     125            0 :     return CFD_ERROR_UNSUPPORTED;
     126              : }
        

Generated by: LCOV version 2.0-1