# SolverChallenge23_Sample_Code **Repository Path**: SolverChallenge23/SolverChallenge23_sample_code ## Basic Information - **Project Name**: SolverChallenge23_Sample_Code - **Description**: solverchallenge23 sample code for direct solver, iterative solver, MPI direct solver, MPI iterative solver. - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2023-06-07 - **Last Updated**: 2024-05-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SolverChallenge23 sample ------------------- ## Introduction There are four sample codes for SolveChallenge23: direct_solver.c , iterative_solver.c , MPI_direct_solver.c and MPI_iterative_solver.c . The sample of solving a matrix using different methods and the specific output form of the submitted results. ## Structure of code ``` README instructions on installation direct_solver.c direct solver code sample MPI_direct_solver.c MPI direct solver code sample iterative_solver.c iterative solver code sample MPI_iterative_solver.c MPI iterative solver code sample mysolver.h your solver code mmio.h read matrix file mmio_highlevel.h read matrix interface utlise.h check answer and memory function file make.inc compiler and compile path Makefile Compile file ``` ## Installation You need to update compiler and compile path in file make.inc and run the command: > **make** ## run command After installation, four executable files will be generated as follows: ``` direct_solver direct solver sample MPI_direct_solver MPI direct solver sample iterative_solver iterative solver sample MPI_iterative_solver MPI iterative solver sample ``` The executable has four parameters, two of which are optional: > **./executable_file matrix_name.mtx vector_name.rhs base-0/1[options] out_type[options]** For base-0/1 if no base is entered, the default is 0. ``` base-0 read matrix base-0 base-1 read matrix base-1 ``` A total of three outputs are provided for the output type (default is 0): ``` type: direct solver / iterative solver type - 0 end to end time / end to end time type - 1 solver + solve time / preprocess + solver time type - 2 solve time / solver time ``` ## Output If the matrix is solved by the direct method, the output is as follows: ``` matrix name : matrix_name.mtx vectorb name : vector_name.rhs read function : base-X type : X ------------------------------------------ CHECK [option out_type time] X.XXXXXX ms check type-X time Check || AX - B || 2 = X.XXXXXXe-XX check || AX - B || 2 answer Check || AX - B || MAX = X.XXXXXXe-XX check || AX - B || MAX answer Check || AX - B || 2 / || B || 2 = X.XXXXXXe-XX check || AX - B || 2 / || B || 2 answer Total memory usage: XXXX.XXXXX MB check the memory cost ``` If the matrix is solved by the iterative method, the output is as follows: ``` matrix name : matrix_name.mtx vectorb name : vector_name.rhs read function : base-X type : X ------------------------------------------ CHECK [option out_type time] X.XXXXXX ms check type-X time Check || AX - B || 2 = X.XXXXXXe-XX check || AX - B || 2 answer Check || AX - B || MAX = X.XXXXXXe-XX check || AX - B || MAX answer Check || AX - B || 2 / || B || 2 = X.XXXXXXe-XX check || AX - B || 2 / || B || 2 answer Total memory usage: XXXX.XXXXX MB check the memory cost ``` Samples use the type double to calculate the final result, which can be replaced by a higher precision (e.g. long double) for testing. ## Execution of Sample ### run the sample for direct solver ``` ./direct_solver matrix_name.mtx vector_name.rhs base-0/1[options] out_type[options] ``` for iterative solver ``` ./iterative_solver matrix_name.mtx vector_name.rhs base-0/1[options] out_type[options] ``` ### run the MPI sample for MPI direct solver ``` mpirun -np MPI_number ./MPI_direct_solver matrix_name.mtx vector_name.rhs base-0/1[options] out_type[options] ``` for MPI iterative solver ``` mpirun -np MPI_number ./MPI_iterative_solver matrix_name.mtx vector_name.rhs base-0/1[options] out_type[options] ```