Proposal of new interface for mixed precision functions

Open discussion for MAGMA

Proposal of new interface for mixed precision functions

Postby jgpallero » Tue Jan 07, 2014 7:26 am

Hello,

I would like to propose a new interface for the mixed precision routines (ds/zc)GESV, (ds/zc)POSV and others that MAGMA also contains. Actually is not a proposal of changing the interface of the existing functions, but create newer ones. My suggestion is adding a new input argument in order to control if the double precision computation will be executed if the refinement process fails. Now, this LAPACK functions always switch to the double precision algorithm to solve the problem. I'm thinking, for example, in cases that the GPU is single precision powerful, but has only poor performance in double. In such cases, if the mixed precision fails the operator may want to solve the problem in double using the CPU only, as it is probably faster than a non high-end GPU. So I propose the new input argument can adopt two values: 0 or not 0. When the value is 0 and the mixed algorithm fails, the function runs as the classical one and uses the double precision function to solve the task. But if not 0 is passed and the mixed algorithm fails, the function returns and is the responsibility of the programmer by inspecting the *info and *iter output arguments to call the double precision function for completing the task. The function declaration (for dsgesv_stop, or whatever other name) could be:
Code: Select all
magma_dsgesv_stop_gpu(char trans, magma_int_t n, magma_int_t nrhs,
                 double *dA, magma_int_t ldda,
                 magma_int_t *ipiv,  magma_int_t *dipiv,
                 double *dB, magma_int_t lddb,
                 double *dX, magma_int_t lddx,
                 double *dworkd, float *dworks,
                 magma_int_t stop,
                 magma_int_t *iter, magma_int_t *info)


where 'magma_int_t stop' is the proposed argument

Thanks
Last edited by jgpallero on Tue Jan 07, 2014 12:19 pm, edited 3 times in total.
jgpallero
 
Posts: 29
Joined: Tue Nov 15, 2011 12:38 pm

Re: Proposal of new interface for mixed precision functions

Postby jgpallero » Tue Jan 07, 2014 10:09 am

Hello again,

I've inspected the code, and adding the new proposed functions is straightforward. For the dsgesv_stop_gpu (or other better name) only three lines of code should be added as (putting in context):
Code: Select all
/* If we are at this place of the code, this is because we have
     * performed ITER=ITERMAX iterations and never satisified the
     * stopping criterion. Set up the ITER flag accordingly and follow
     * up on double precision routine. */
    *iter = -ITERMAX - 1;

FALLBACK:

    /* Check if the double precision routine must be used */
    if (stop) {
        return *info;
    }

    /* Single-precision iterative refinement failed to converge to a
     * satisfactory solution, so we resort to double precision. */
    magma_dgetrf_gpu( n, n, dA, ldda, ipiv, info );


For dsposv_stop_gpu:
Code: Select all
/* If we are at this place of the code, this is because we have
     * performed ITER=ITERMAX iterations and never satisified the
     * stopping criterion. Set up the ITER flag accordingly and follow
     * up on double precision routine. */
    *iter = -ITERMAX - 1;

FALLBACK:

    /* Check if the double precision routine must be used */
    if (stop) {
        return *info;
    }
   
    /* Single-precision iterative refinement failed to converge to a
     * satisfactory solution, so we resort to double precision. */
    magma_dpotrf_gpu( uplo, n, dA, ldda, info );


And for dsgeqrsv_stop_gpu:
Code: Select all
FALLBACK:
    /* Single-precision iterative refinement failed to converge to a
     * satisfactory solution, so we resort to double precision. */
    magma_free( dworks );
    magma_free_cpu( hworks );

    /* Check if the double precision routine must be used */
    if (stop) {
        magma_free( dworkd );
        return *info;
    }

    /*
     * Allocate temporary buffers
     */
    /* dworkd = dT for zgeqrf */
    nb   = magma_get_dgeqrf_nb( m );


The code for the dsgesv_gpu, dsposv_gpu and dsgeqrsv_gpu would the be based on calls to the new functions with STOP=0

Also the same for its zcXXXXX counterparts, of course

What do you think?

Thanks
jgpallero
 
Posts: 29
Joined: Tue Nov 15, 2011 12:38 pm


Return to User discussion

Who is online

Users browsing this forum: Google [Bot] and 3 guests