Esempio n. 1
0
extern "C" magma_int_t
magma_c_precondsetup(
    magma_c_sparse_matrix A, magma_c_vector b, 
    magma_c_preconditioner *precond,
    magma_queue_t queue )
{
    if ( precond->solver == Magma_JACOBI ) {
        magma_cjacobisetup_diagscal( A, &(precond->d), queue );
        return MAGMA_SUCCESS;
    }
    else if ( precond->solver == Magma_PASTIX ) {
        magma_cpastixsetup( A, b, precond, queue );
        return MAGMA_SUCCESS;
    }
    else if ( precond->solver == Magma_ILU ) {
        magma_ccumilusetup( A, precond, queue );
        return MAGMA_SUCCESS;
    }
    else if ( precond->solver == Magma_ICC ) {
        magma_ccumiccsetup( A, precond, queue );
        return MAGMA_SUCCESS;
    }
    else if ( precond->solver == Magma_NONE ) {
        return MAGMA_SUCCESS;
    }
    else {
        printf( "error: preconditioner type not yet supported.\n" );
        return MAGMA_ERR_NOT_SUPPORTED;
    }
}
Esempio n. 2
0
extern "C" magma_int_t
magma_c_precondsetup(
    magma_c_matrix A, magma_c_matrix b,
    magma_c_solver_par *solver,
    magma_c_preconditioner *precond,
    magma_queue_t queue )
{
    magma_int_t info = 0;
    
    
    //Chronometry
    real_Double_t tempo1, tempo2;
    
    tempo1 = magma_sync_wtime( queue );
    
    if( A.num_rows != A.num_cols ){
        printf("%% warning: non-square matrix.\n");
        printf("%% Fallback: no preconditioner.\n");
        precond->solver = Magma_NONE;
    } 
    
    if ( precond->solver == Magma_JACOBI ) {
        info = magma_cjacobisetup_diagscal( A, &(precond->d), queue );
    }
    else if ( precond->solver == Magma_PASTIX ) {
        //info = magma_cpastixsetup( A, b, precond, queue );
        info = MAGMA_ERR_NOT_SUPPORTED;
    }
    else if ( precond->solver == Magma_ILU ) {
        info = magma_ccumilusetup( A, precond, queue );
    }
    else if ( precond->solver == Magma_ICC ) {
        info = magma_ccumiccsetup( A, precond, queue );
    }
    else if ( precond->solver == Magma_AICC ) {
        info = magma_citericsetup( A, b, precond, queue );
    }
    else if ( precond->solver == Magma_AICT ) {
        #ifdef _OPENMP
            info = magma_citerictsetup( A, b, precond, queue );
            precond->solver = Magma_AICC; // handle as AICC
        #else
            printf( "error: preconditioner requires OpenMP.\n" );
            info = MAGMA_ERR_NOT_SUPPORTED;
        #endif
    }
    else if ( precond->solver == Magma_AILU ) {
        info = magma_citerilusetup( A, b, precond, queue );
    }
    else if ( precond->solver == Magma_CUSTOMIC ) {
        info = magma_ccustomicsetup( A, b, precond, queue );
        precond->solver = Magma_AICC; // handle as AICC
    }
    else if ( precond->solver == Magma_CUSTOMILU ) {
        info = magma_ccustomilusetup( A, b, precond, queue );
        precond->solver = Magma_AILU; // handle as AILU
    }
    else if ( precond->solver == Magma_NONE ) {
        info = MAGMA_SUCCESS;
    }
    else {
        printf( "error: preconditioner type not yet supported.\n" );
        info = MAGMA_ERR_NOT_SUPPORTED;
    }
    if( 
        ( solver->solver == Magma_PQMR  || 
          solver->solver == Magma_PBICG ||
          solver->solver == Magma_LSQR ) &&
        ( precond->solver == Magma_ILU      || 
            precond->solver == Magma_AILU   || 
            precond->solver == Magma_ICC    || 
            precond->solver == Magma_AICC ) ) {  // also prepare the transpose
        info = magma_ccumilusetup_transpose( A, precond, queue );
    }
    
    tempo2 = magma_sync_wtime( queue );
    precond->setuptime += tempo2-tempo1;
    
    return info;
}