LCOV - code coverage report
Current view: top level - solvers/gpu - solver_gpu_stub.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 44.1 % 102 45
Test Date: 2026-10-05 04:47:18 Functions: 35.3 % 17 6

            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            5 : gpu_config_t gpu_config_default(void) {
      16            5 :     gpu_config_t config;
      17            5 :     memset(&config, 0, sizeof(gpu_config_t));
      18            5 :     config.enable_gpu = 0;  // Disabled by default when CUDA not available
      19            5 :     config.min_grid_size = 10000;
      20            5 :     config.min_steps = 10;
      21            5 :     config.block_size_x = 16;
      22            5 :     config.block_size_y = 16;
      23            5 :     config.poisson_max_iter = 1000;
      24            5 :     config.poisson_tolerance = 1e-3;  // Match the CUDA gpu_config_default() and header docs
      25            5 :     config.persistent_memory = 1;
      26            5 :     config.async_transfers = 1;
      27            5 :     config.sync_after_kernel = 0;
      28            5 :     config.verbose = 0;
      29            5 :     return config;
      30              : }
      31              : 
      32           56 : int gpu_is_available(void) {
      33           56 :     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            6 : 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            6 :     (void)field;
     109            6 :     (void)grid;
     110            6 :     (void)params;
     111            6 :     (void)config;
     112              : 
     113            6 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU solver: CUDA not available (compiled without CUDA support)");
     114            6 :     return CFD_ERROR_UNSUPPORTED;
     115              : }
     116              : 
     117            6 : 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            6 :     (void)field;
     120            6 :     (void)grid;
     121            6 :     (void)params;
     122            6 :     (void)config;
     123              : 
     124            6 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU projection solver: CUDA not available (compiled without CUDA support)");
     125            6 :     return CFD_ERROR_UNSUPPORTED;
     126              : }
     127              : 
     128            0 : cfd_status_t solve_explicit_euler_method_gpu(flow_field* field, const grid* grid,
     129              :                                              const ns_solver_params_t* params,
     130              :                                              const gpu_config_t* config) {
     131            0 :     (void)field;
     132            0 :     (void)grid;
     133            0 :     (void)params;
     134            0 :     (void)config;
     135              : 
     136            0 :     cfd_set_error(CFD_ERROR_UNSUPPORTED,
     137              :                   "GPU explicit Euler solver: CUDA not available (compiled without CUDA support)");
     138            0 :     return CFD_ERROR_UNSUPPORTED;
     139              : }
     140              : 
     141            6 : cfd_status_t solve_rk2_method_gpu(flow_field* field, const grid* grid,
     142              :                                   const ns_solver_params_t* params, const gpu_config_t* config) {
     143            6 :     (void)field;
     144            6 :     (void)grid;
     145            6 :     (void)params;
     146            6 :     (void)config;
     147              : 
     148            6 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU RK2 solver: CUDA not available (compiled without CUDA support)");
     149            6 :     return CFD_ERROR_UNSUPPORTED;
     150              : }
     151              : 
     152            6 : cfd_status_t solve_rk4_method_gpu(flow_field* field, const grid* grid,
     153              :                                   const ns_solver_params_t* params, const gpu_config_t* config) {
     154            6 :     (void)field;
     155            6 :     (void)grid;
     156            6 :     (void)params;
     157            6 :     (void)config;
     158              : 
     159            6 :     cfd_set_error(CFD_ERROR_UNSUPPORTED, "GPU RK4 solver: CUDA not available (compiled without CUDA support)");
     160            6 :     return CFD_ERROR_UNSUPPORTED;
     161              : }
        

Generated by: LCOV version 2.0-1