tile.c 4.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**
 *
 * @copyright (c) 2009-2014 The University of Tennessee and The University 
 *                          of Tennessee Research Foundation. 
 *                          All rights reserved.
 * @copyright (c) 2012-2014 Inria. All rights reserved.
 * @copyright (c) 2012-2014 IPB. All rights reserved. 
 *
 **/

/**
 *
 * @file tile.c
 *
 *  MORSE auxiliary routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
19
 * @version 0.9.0
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
 * @author Jakub Kurzak
 * @author Cedric Castagnede
 * @date 2010-11-15
 *
 **/
#include "common.h"
#include "auxiliary.h"
#include "tile.h"

/*******************************************************************************
 *
 * @ingroup Auxiliary
 *
 *  MORSE_Lapack_to_Tile - Conversion from LAPACK layout to tile layout.
 *
 *******************************************************************************
 *
 * @param[in] Af77
 *          LAPACK matrix.
 *
 * @param[in] LDA
 *          The leading dimension of the matrix Af77.
 *
 * @param[out] A
 *          Descriptor of the MORSE matrix in tile layout.
 *
 *******************************************************************************
 *
 * @return
 *          \retval MORSE_SUCCESS successful exit
 *
 ******************************************************************************/
int MORSE_Lapack_to_Tile(void *Af77, int LDA, MORSE_desc_t *A)
{
    MORSE_context_t  *morse;
    MORSE_sequence_t *sequence = NULL;
    MORSE_request_t   request;
    int status;

    morse = morse_context_self();
    if (morse == NULL) {
        morse_fatal_error("MORSE_Lapack_to_Tile", "MORSE not initialized");
        return MORSE_ERR_NOT_INITIALIZED;
    }
    /* Check descriptor for correctness */
    if (morse_desc_check(A) != MORSE_SUCCESS) {
        morse_error("MORSE_Lapack_to_Tile", "invalid descriptor");
        return MORSE_ERR_ILLEGAL_VALUE;
    }
    morse_sequence_create(morse, &sequence);
    switch( A->dtyp ) {
#if defined(PRECISION_s)
    case MorseRealFloat:
        morse_pslapack_to_tile(Af77, LDA, A, sequence, &request);
        break;
#endif

#if defined(PRECISION_d)
    case MorseRealDouble:
        morse_pdlapack_to_tile(Af77, LDA, A, sequence, &request);
        break;
#endif

#if defined(PRECISION_c)
    case MorseComplexFloat:
        morse_pclapack_to_tile(Af77, LDA, A, sequence, &request);
        break;
#endif

#if defined(PRECISION_z)
    case MorseComplexDouble:
        morse_pzlapack_to_tile(Af77, LDA, A, sequence, &request);
        break;
#endif

    default:
        morse_error("MORSE_Lapack_to_Tile", "Type unknown");
    }
    RUNTIME_barrier(morse);
    status = sequence->status;
    morse_sequence_destroy(morse, sequence);
    return status;
}

/*******************************************************************************
 *
 * @ingroup Auxiliary
 *
 *  MORSE_Tile_to_Lapack - Conversion from tile layout to LAPACK layout.
 *
 *******************************************************************************
 *
 * @param[out] A
 *          Descriptor of the MORSE matrix in tile layout.
 *
 * @param[in] Af77
 *          LAPACK matrix.
 *
 * @param[in] LDA
 *          The leading dimension of the matrix Af77.
 *
 *******************************************************************************
 *
 * @return
 *          \retval MORSE_SUCCESS successful exit
 *
 ******************************************************************************/
int MORSE_Tile_to_Lapack(MORSE_desc_t *A, void *Af77, int LDA)
{
    MORSE_context_t  *morse;
    MORSE_sequence_t *sequence = NULL;
    MORSE_request_t   request;
    int status;

    morse = morse_context_self();
    if (morse == NULL) {
        morse_fatal_error("MORSE_Tile_to_Lapack", "MORSE not initialized");
        return MORSE_ERR_NOT_INITIALIZED;
    }
    /* Check descriptor for correctness */
    if (morse_desc_check(A) != MORSE_SUCCESS) {
        morse_error("MORSE_Tile_to_Lapack", "invalid descriptor");
        return MORSE_ERR_ILLEGAL_VALUE;
    }
    morse_sequence_create(morse, &sequence);
    switch( A->dtyp ) {
#if defined(PRECISION_s)
    case MorseRealFloat:
        morse_pstile_to_lapack(A, Af77, LDA, sequence, &request);
        break;
#endif

#if defined(PRECISION_d)
    case MorseRealDouble:
        morse_pdtile_to_lapack(A, Af77, LDA, sequence, &request);
        break;
#endif

#if defined(PRECISION_c)
    case MorseComplexFloat:
        morse_pctile_to_lapack(A, Af77, LDA, sequence, &request);
        break;
#endif

#if defined(PRECISION_z)
    case MorseComplexDouble:
        morse_pztile_to_lapack(A, Af77, LDA, sequence, &request);
        break;
#endif

    default:
        morse_error("MORSE_Tile_to_Lapack", "Type unknown");
    }
    RUNTIME_barrier(morse);
    status = sequence->status;
    morse_sequence_destroy(morse, sequence);
    return status;
}