You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.9 KiB
C
129 lines
3.9 KiB
C
|
1 week ago
|
#pragma once
|
||
|
|
|
||
|
|
#ifdef _WIN32
|
||
|
|
# ifdef ACCELWT_DLL_EXPORTS
|
||
|
|
# define ACCELWT_API __declspec(dllexport)
|
||
|
|
# else
|
||
|
|
# define ACCELWT_API __declspec(dllimport)
|
||
|
|
# endif
|
||
|
|
#else
|
||
|
|
# define ACCELWT_API
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
enum AccelWTStatus
|
||
|
|
{
|
||
|
|
ACCELWT_STATUS_SUCCESS = 0,
|
||
|
|
ACCELWT_STATUS_INVALID_ARGUMENT = 1,
|
||
|
|
ACCELWT_STATUS_CREATE_FAILED = 2,
|
||
|
|
ACCELWT_STATUS_SETUP_FAILED = 3,
|
||
|
|
ACCELWT_STATUS_SOLVE_FAILED = 4,
|
||
|
|
ACCELWT_STATUS_NOT_CONVERGED = 5,
|
||
|
|
ACCELWT_STATUS_UNSUPPORTED_BACKEND = 6
|
||
|
|
};
|
||
|
|
|
||
|
|
typedef struct AccelWTSolveOptions
|
||
|
|
{
|
||
|
|
int max_iter;
|
||
|
|
double rel_tol;
|
||
|
|
double abs_tol;
|
||
|
|
int ilu_jacobi_iters;
|
||
|
|
int omp_threads;
|
||
|
|
int use_initial_guess;
|
||
|
|
} AccelWTSolveOptions;
|
||
|
|
|
||
|
|
typedef struct AccelWTSolveInfo
|
||
|
|
{
|
||
|
|
int iterations;
|
||
|
|
double final_rel_residual;
|
||
|
|
double setup_seconds;
|
||
|
|
int status;
|
||
|
|
} AccelWTSolveInfo;
|
||
|
|
|
||
|
|
typedef struct AccelWTDatasetOptions
|
||
|
|
{
|
||
|
|
const char *dataset_dir;
|
||
|
|
int lagged_ilu_k;
|
||
|
|
int lagged_ilu_max_iters;
|
||
|
|
int solve_omp_threads;
|
||
|
|
int host_residual_interval;
|
||
|
|
int print_progress;
|
||
|
|
} AccelWTDatasetOptions;
|
||
|
|
|
||
|
|
typedef struct AccelWTDatasetSummary
|
||
|
|
{
|
||
|
|
int num_steps;
|
||
|
|
int total_solves;
|
||
|
|
int early_exit_steps;
|
||
|
|
int ilu_refresh_steps;
|
||
|
|
int ilu_lagged_reuse_steps;
|
||
|
|
int not_converged_steps;
|
||
|
|
long long total_iterations;
|
||
|
|
double time_read_t;
|
||
|
|
double time_read_b;
|
||
|
|
double time_read_a;
|
||
|
|
double time_csr;
|
||
|
|
double time_create;
|
||
|
|
double time_prepare_step;
|
||
|
|
double time_solve;
|
||
|
|
double time_total;
|
||
|
|
double avg_prepare_ms;
|
||
|
|
double avg_solve_ms;
|
||
|
|
int status;
|
||
|
|
} AccelWTDatasetSummary;
|
||
|
|
|
||
|
|
ACCELWT_API const char *accelwt_backend_name(void);
|
||
|
|
|
||
|
|
ACCELWT_API void accelwt_default_options(AccelWTSolveOptions *options);
|
||
|
|
|
||
|
|
ACCELWT_API void accelwt_default_dataset_options(AccelWTDatasetOptions *options);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_csr(int n,
|
||
|
|
int nnz,
|
||
|
|
const int *row_ptr,
|
||
|
|
const int *col_ind,
|
||
|
|
const double *values,
|
||
|
|
const double *b,
|
||
|
|
double *x,
|
||
|
|
const AccelWTSolveOptions *options,
|
||
|
|
AccelWTSolveInfo *info);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_csr_cpu(int n,
|
||
|
|
int nnz,
|
||
|
|
const int *row_ptr,
|
||
|
|
const int *col_ind,
|
||
|
|
const double *values,
|
||
|
|
const double *b,
|
||
|
|
double *x,
|
||
|
|
const AccelWTSolveOptions *options,
|
||
|
|
AccelWTSolveInfo *info);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_csr_cuda(int n,
|
||
|
|
int nnz,
|
||
|
|
const int *row_ptr,
|
||
|
|
const int *col_ind,
|
||
|
|
const double *values,
|
||
|
|
const double *b,
|
||
|
|
double *x,
|
||
|
|
const AccelWTSolveOptions *options,
|
||
|
|
AccelWTSolveInfo *info);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_dataset_cpu(const char *dataset_dir,
|
||
|
|
const AccelWTDatasetOptions *options,
|
||
|
|
AccelWTDatasetSummary *summary);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_dataset_cuda(const char *dataset_dir,
|
||
|
|
const AccelWTDatasetOptions *options,
|
||
|
|
AccelWTDatasetSummary *summary);
|
||
|
|
|
||
|
|
ACCELWT_API int accelwt_solve_dataset(const char *dataset_dir,
|
||
|
|
const AccelWTDatasetOptions *options,
|
||
|
|
AccelWTDatasetSummary *summary);
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|