Running tests fail and visual studio configuration

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Running tests fail and visual studio configuration

Post by hartwig anzt » Sun Mar 15, 2015 3:40 pm

I ran the tests in the ubuntu framework (also mac) using gcc and icc compiler.

Are any routines working in your environment?

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Mon Mar 16, 2015 9:55 am

I noticed that in that in source code magma_dmino.cpp, you have code which assign number of rows and cols to magma_d_sparse_matrix.

A piece of code in magma_dmino.cpp

Code: Select all

  (A->num_rows) = (magma_index_t) num_rows;
  (A->num_cols) = (magma_index_t) num_cols;
  (A->nnz)   = (magma_index_t) num_nonzeros;

Part of the definition of struct magma_d_sparse_matrix

Code: Select all

typedef struct magma_d_sparse_matrix{

    magma_storage_t    storage_type;            // matrix format - CSR, ELL, SELL-P
    magma_location_t   memory_location;         // CPU or DEV
    magma_symmetry_t   sym;                     // opt: indicate symmetry
    magma_diagorder_t  diagorder_type;          // opt: only needed for factorization matrices
    magma_fillmode_t   fill_mode;               // fill mode full/lower/upper
    magma_int_t        num_rows;                // number of rows
    magma_int_t        num_cols;                // number of columns
    magma_int_t        nnz;                     // opt: number of nonzeros
    magma_int_t        max_nnz_row;             // opt: max number of nonzeros in one row
    magma_int_t        diameter; 
}
In the struct, num_rows, num_cols, nnz, etc.are type of magma_int_t, but in magma_dmino.cpp, the code cast them to magma_index_t. In my environment, I am using MKL, thus, magma_int_t in my code is type of long long int and magma_index_t is type of int. I would like to know why the code do this cast?

mgates3
Posts: 918
Joined: Fri Jan 06, 2012 2:13 pm

Re: Running tests fail and visual studio configuration

Post by mgates3 » Mon Mar 16, 2015 10:29 am

You said, "I am using MKL, thus, magma_int_t in my code is [of] type long long int and magma_index_t is [of] type int."

Using long long int is not required with MKL, though it should work. Did you define MKL_ILP64 via the pre-processor in order to get long long int? Did you link with the MKL ilp64 libraries? Both are required for correct, consistent code.

magma_index_t is always int because cusparse uses int for its sparse matrix indices. magma_int_t is either int or long long int, depending on whether you link with LP64 libraries or (define MKL_ILP64 and link with ILP64 libraries).

-mark

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Mon Mar 16, 2015 10:52 am

I actually recompile the sparse-iter in Visual Studio by setting Intel Performance Libraries
1. Use Intel MKL ---> Parallel
2. Use ILP64 interfaces --->Yes
3. Use MPI library--->Intel(R) MPI

After this, I rerun test, it works properly now.

Thank you for your patience!

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Tue Mar 17, 2015 4:29 pm

I run successfully of my code use magma_d_solver with matrix memplus.mtx.
I choose Magma_BICGSTAB as my solver and the matrix memplus.mtx is NON-positive definite.

My code and matrix specification are below:

My code:

Code: Select all

// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include<iostream>

// includes, project
#include "flops.h"
#include "magma.h"
#include "magmasparse.h"
#include "magma_lapack.h"
#include "testings.h"


int main(  int argc, char** argv )
{
	//sparse matrix A
	magma_d_sparse_matrix A;
	
    magma_queue_t queue;
    magma_queue_create(&queue);
	
	//const char *filename="smallMat.mtx";
	const char *filename="memplus.mtx";
	magma_d_csr_mtx(&A, filename, queue);
	
	
	//copy sparse matrix A to device memory
	magma_d_sparse_matrix B_d;
    magma_d_mtransfer(A, &B_d, Magma_CPU, Magma_DEV, queue);


	//vector x and b
	magma_d_vector x, b;
	double one = MAGMA_D_MAKE(1.0, 0.0);
    double zero = MAGMA_D_MAKE(0.0, 0.0);
	double pointNine=MAGMA_D_MAKE(0.9, 0.0);
	magma_d_vinit(&b, Magma_DEV, A.num_cols, one, queue);
    magma_d_vinit(&x, Magma_DEV, A.num_cols, one, queue);


    magma_d_spmv(one, B_d, x, zero, b, queue);                 //  b = A x
    magma_d_vfree(&x, queue);
    magma_d_vinit(&x, Magma_DEV, A.num_cols, one, queue);


	//intialize solver and preconditioner
	magma_dopts zopts;
	magma_dsolverinfo_init(&zopts.solver_par, &zopts.precond_par, queue);
	zopts.solver_par.solver=Magma_BICGSTAB;
	zopts.solver_par.epsilon=0.00001;
	zopts.solver_par.maxiter=1000;
	zopts.solver_par.verbose=0;
	zopts.solver_par.restart=10;
	zopts.solver_par.ortho=Magma_CGS;
	//zopts.precond_par.solver=Magma_ILU;
	zopts.precond_par.solver=Magma_NONE;


	//general solver
	magma_d_solver(B_d, b, &x, &zopts, queue);	
	//magma_dpgmres(A, b, &x, &zopts.solver_par, &zopts.precond_par, queue);

	//show feedback
	magma_dsolverinfo(&zopts.solver_par, &zopts.precond_par, queue);


	//free everything
	magma_d_mfree(&B_d, queue);
    magma_d_mfree(&A, queue); 
    magma_d_vfree(&x, queue);
    magma_d_vfree(&b, queue);
	magma_dsolverinfo_free( &zopts.solver_par, &zopts.precond_par, queue);
	magma_queue_destroy( queue );
    TESTING_FINALIZE();	
}

Matrix properties:

Code: Select all

number of rows	17,758
number of columns	17,758
nonzeros	99,147
structural full rank?	yes
structural rank	17,758
# of blocks from dmperm	23
# strongly connected comp.	23
explicit zero entries	27,003
nonzero pattern symmetry	symmetric
numeric value symmetry	50%
type	real
structure	unsymmetric
Cholesky candidate?	no
positive definite?	no

Results:

Code: Select all

# Reading sparse matrix from file (memplus.mtx): done
#=============================================================#
# BiCGStab solver summary:
#    initial residual: 2.214608e+000
#    iterations:  366
#    iterative residual: 2.077416e-005
#    exact final residual: 2.077416e-005
#    runtime: 0.2672 sec
#    solver info: 0
#=============================================================#

I would like to know am I suppose to get error of MAGMA_NONSPD based on the code in dbicgstab.cpp? Thank you?

I have attached memplus matrix.
Attachments
memplus.txt
(3.24 MiB) Downloaded 128 times

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Thu Mar 19, 2015 2:59 pm

I would like to have some additional questions:

1. I would like to know why the magma_dbicgstab solver requires the input sparse matrix to be real symmetric and positive definite?
2. Could you please provide me some matrices that allows me to verify my sparse-iter module building successfully for running bicgstab with preconditioner?

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Running tests fail and visual studio configuration

Post by hartwig anzt » Thu Mar 19, 2015 8:10 pm

1. No, BiCGSTAB does not require the linear system to be SPD.

2. run

./testing_dsolver --solver 5 --precond 1 --verbose 10 --maxiter 1000 LAPLACE2D 100
( Jacobi-preconditioned BiCGSTAB on a 2D Laplace with problem size 10000)

the output should look like:

./testing_dsolver --solver 5 --precond 1 --verbose 10 --maxiter 1000 LAPLACE2D 100
MAGMA 1.5.0 svn compiled for CUDA capability >= 3.0
CUDA runtime 6000, driver 6050. MAGMA not compiled with OpenMP.
ndevices 1
device 0: GeForce GT 750M, 925.5 MHz clock, 2047.6 MB memory, capability 3.0
Usage: ./testing_dsolver [options] [-h|--help] matrices


# matrix info: 10000-by-10000 with 49798 nonzeros

#=============================================================#
# Jacobi-BiCGStab performance analysis every 10 iteration
# iter || residual-nrm2 || runtime
#=============================================================#
0 || 2.019901e+01 || 0.000000
10 || 8.564695e-01 || 0.020817
20 || 3.520037e-01 || 0.032803
30 || 2.096109e-01 || 0.044626
40 || 1.460718e-01 || 0.065002
50 || 1.115354e-01 || 0.077119
60 || 9.925142e-02 || 0.088831
70 || 7.976463e-02 || 0.100787
80 || 1.776861e-02 || 0.116065
90 || 4.301034e-03 || 0.133229
100 || 1.284169e-03 || 0.145184
110 || 1.600201e-03 || 0.160172
120 || 7.847614e-05 || 0.172023
130 || 2.178489e-05 || 0.189881
140 || 5.196415e-07 || 0.201624
150 || 4.823035e-08 || 0.216586
160 || 8.140691e-09 || 0.234424
170 || 1.249090e-10 || 0.247091
180 || 2.476491e-11 || 0.255924
190 || 1.389877e-12 || 0.265939
200 || 6.003884e-13 || 0.277433
#=============================================================#
# BiCGStab solver summary:
# initial residual: 2.019901e+01
# iterations: 204
# iterative residual: 7.221859e-15
# exact final residual: 3.014919e-13
# runtime: 0.2809 sec
# solver info: 0
#=============================================================#

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Fri Mar 20, 2015 9:45 am

Thanks for your reply!

I have got a similar result as you, but not exactly the same. The difference is that I am using MAGMA1.6.1 and yours is 1.5.0. Can I think our different results is because of the version difference?

I would also like to know what is the difference between iterative residual and exact residual?

Below is my input and result:


Input:
--solver 5 --verbose 1 --format 0 --maxiter 1000 --mscale 0 --precond 1 LAPLACE2D 100

Result:
MAGMA 1.6.1 compiled for CUDA capability >= 2.0
CUDA runtime 6050, driver 6050. OpenMP threads 8. MKL 11.2.2, MKL threads 4.
ndevices 1
device 0: GeForce GTX 980, 1342.0 MHz clock, 4096.0 MB memory, capability 5.2
Usage: C:\Users\Administrator\Documents\Visual Studio 2010\Projects\magma_test\x64\Debug\magmaTest.exe [options] [-h|--help] matrices


# matrix info: 10000-by-10000 with 49798 nonzeros

#=============================================================#
# Jacobi-BiCGStab performance analysis every 1 iteration
# iter || residual-nrm2 || runtime
#=============================================================#
0 || 2.019901e+001 || 0.000000
1 || 8.577538e+000 || 0.001000
10 || 8.564695e-001 || 0.007005
20 || 3.520037e-001 || 0.014010
30 || 2.096109e-001 || 0.021015
40 || 1.460718e-001 || 0.028020
50 || 1.115354e-001 || 0.035024
60 || 9.925099e-002 || 0.042029
70 || 7.840752e-002 || 0.049034
80 || 1.865104e-002 || 0.056039
90 || 7.788853e-003 || 0.063044
100 || 1.733566e-003 || 0.069048
110 || 2.509952e-004 || 0.076053
120 || 6.667129e-005 || 0.083058
130 || 9.127845e-006 || 0.090063
140 || 1.783402e-006 || 0.097068
150 || 3.953596e-008 || 0.104073
160 || 1.319496e-009 || 0.111078
170 || 5.868233e-011 || 0.119084
180 || 2.711904e-012 || 0.126088
190 || 3.465138e-014 || 0.133094
191 || 3.694759e-014 || 0.134094
192 || 1.636483e-014 || 0.135095
#=============================================================#
# BiCGStab solver summary:
# initial residual: 2.019901e+001
# iterations: 192
# iterative residual: 1.636483e-014
# exact final residual: 2.743200e-013
# runtime: 0.1351 sec
# solver info: 0
#=============================================================#



I also run the solver with NON SPD matrix bayer10.mtx with input:
--solver 5 --verbose 1 --format 0 --maxiter 1000 --mscale 0 --precond 1 bayer10.mtx


but I got the below result:

MAGMA 1.6.1 compiled for CUDA capability >= 2.0
CUDA runtime 6050, driver 6050. OpenMP threads 8. MKL 11.2.2, MKL threads 4.
ndevices 1
device 0: GeForce GTX 980, 1342.0 MHz clock, 4096.0 MB memory, capability 5.2
Usage: C:\Users\Administrator\Documents\Visual Studio 2010\Projects\magma_test\x64\Debug\magmaTest.exe [options] [-h|--help] matrices

# Reading sparse matrix from file (bayer10.mtx): done

# matrix info: 13436-by-13436 with 71594 nonzeros

Operator A is not postive definite. (Ar,r) = -300187585.639264
#=============================================================#
# Jacobi-BiCGStab performance analysis every 1 iteration
# iter || residual-nrm2 || runtime
#=============================================================#
0 || -6.277439e+066 || -6277438562204192500000000000000000000000000000000000000000000000000.000000
#=============================================================#
# BiCGStab solver summary:
# initial residual: 6.478288e+003
# iterations: 0
# iterative residual: -9.255963e+061
# exact final residual: -9.255963e+061
# runtime: -92559631349317831000000000000000000000000000000000000000000000.0000 sec
# solver info: 0
#=============================================================#

The solver infor==0 which indicates it runs succesfully, but other measurements seems not correct. I would like to know whether there is anything wrong with my usage of this solver?

I have attached the matrix.
The matrix property can be view via this link: http://www.cise.ufl.edu/research/sparse ... yer10.html
Attachments
bayer10.txt
(2.15 MiB) Downloaded 114 times

dannnnn
Posts: 37
Joined: Tue Mar 03, 2015 3:41 pm

Re: Running tests fail and visual studio configuration

Post by dannnnn » Fri Mar 20, 2015 11:00 am

I tried Block-asynchronous iteration solver with matrix rdist3a.mtx and I got the following result and a lots of errors:
If I change the max iteration number to 1, I will get similar result as above.
However, I have no problem running LAPLACE2D 100 using this solver.
I have attached the matrix rdist3a.mtx and its property can be view via this link: http://www.cise.ufl.edu/research/sparse ... ist3a.html

Could you please help me run Block-asynchronous iteration solver with matrix rdist3a.mtx ?


Input:
--solver 10 --verbose 1 --format 0 --maxiter 100 --mscale 0 --precond 1 rdist3a.mtx


Result:

MAGMA 1.6.1 compiled for CUDA capability >= 2.0
CUDA runtime 6050, driver 6050. OpenMP threads 8. MKL 11.2.2, MKL threads 4.
ndevices 1
device 0: GeForce GTX 980, 1342.0 MHz clock, 4096.0 MB memory, capability 5.2
Usage: C:\Users\Administrator\Documents\Visual Studio 2010\Projects\magma_test\x64\Debug\magmaTest.exe [options] [-h|--help] matrices

# Reading sparse matrix from file (rdist3a.mtx): done

# matrix info: 2398-by-2398 with 61896 nonzeros

CUDA runtime error: unknown error (30) in magma_sync_wtime at ..\magma\control\magma_timer.cpp:91
CUDA runtime error: unknown error (30) in magma_d_mfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:269
Memory Free Error.
CUDA runtime error: unknown error (30) in magma_d_mfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:269
Memory Free Error.
CUDA runtime error: unknown error (30) in magma_d_mfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:269
Memory Free Error.
#=============================================================#
# Block-asynchronous iteration solver summary:
# initial residual: 1.618108e+003
# iterations: 100
# exact final residual: 0.000000e+000
# runtime: 0.0010 sec
# solver info: 0
#=============================================================#
CUDA runtime error: unknown error (30) in magma_d_mfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:269
Memory Free Error.
CUDA runtime error: unknown error (30) in magma_d_vfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:68
Memory Free Error.
CUDA runtime error: unknown error (30) in magma_d_vfree at ..\..\..\..\..\..\..\magma\sparse-iter\control\magma_d_free.cpp:68
Memory Free Error.
CUDA runtime error: unknown error (30) in magma_sync_wtime at ..\magma\control\magma_timer.cpp:91
CUDA runtime error: unknown error (30) in main at ..\..\..\..\..\Desktop\testing_dsolver.cpp:190

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Running tests fail and visual studio configuration

Post by hartwig anzt » Fri Mar 20, 2015 11:25 am

the matrix rdist3a.mtx contains zeros on the diagonal - Jacobi or block-asynchronous iteration will not work for this! However, I apologize for the code crashing, I will fix it to have a appropriate error message.
Thanks, Hartwig

Post Reply