Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2379964e authored by Mathieu Faverge's avatar Mathieu Faverge
Browse files

Add hmat kernel interface

parent 4db899ca
No related branches found
No related tags found
1 merge request!203Integrate H-Mat support via hmat-oss
/**
*
* @file core_zhmat.c
*
* @copyright 2019-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
* @copyright 2019-2019 Universidad Jaume I. All rights reserved.
*
* @brief Chameleon CPU kernel interface from CHAM_tile_t layout to the real one.
*
* @version 1.0.0
* @author Rocio Carratala-Saez
* @author Mathieu Faverge
* @date 2019-12-02
* @precisions normal z -> c d s
*
*/
#include "coreblas/hmat.h"
/**
* @brief The hmat interface to the C++ functions
*/
hmat_interface_t hmat_zinterface;
void __hmat_zinit() __attribute__(( constructor ));
void __hmat_zinit() {
hmat_init_default_interface( &hmat_zinterface, HMAT_DOUBLE_COMPLEX );
}
void __hmat_zfini() __attribute__(( destructor ));
void __hmat_zfini() {
hmat_zinterface.finalize();
}
int hmat_zpotrf( hmat_matrix_t *A ) {
hmat_factorization_context_t ctx_facto;
hmat_factorization_context_init( &ctx_facto );
ctx_facto.factorization = hmat_factorization_llt;
hmat_zinterface.factorize_generic( A, &ctx_facto );
return 0;
}
int hmat_zgetrf( hmat_matrix_t *A ) {
hmat_factorization_context_t ctx_facto;
hmat_factorization_context_init( &ctx_facto );
ctx_facto.factorization = hmat_factorization_lu;
hmat_zinterface.factorize_generic( A, &ctx_facto );
return 0;
}
int hmat_zgemm( char transA, char transB, void* alpha, hmat_matrix_t* A,
hmat_matrix_t* B, void* beta, hmat_matrix_t* C ) {
return hmat_zinterface.gemm( transA, transB, alpha, A, B, beta, C );
}
int hmat_zgemv( char transA, void* alpha, hmat_matrix_t* A,
void* B, void* beta, void* C, int nrhs ) {
return hmat_zinterface.gemm_scalar( transA, alpha, A, B, beta, C, nrhs );
}
int hmat_ztrsm( char side, char uplo, char trans, char diag, int m, int n,
void* alpha, hmat_matrix_t* A, int is_b_hmat, void* B ) {
return hmat_zinterface.trsm( side, uplo, trans, diag, m, n, alpha, A, is_b_hmat, B );
}
hmat_matrix_t *hmat_zread( void *buffer ) {
hmat_buffer_comm_t buffer_struct = { 0, (char*)buffer };
hmat_matrix_t *hmat = hmat_zinterface.read_struct( (hmat_iostream)(&buffer_comm_read),
(void *)(&buffer_struct) );
hmat_zinterface.read_data( hmat, (hmat_iostream)(&buffer_comm_read), (void *)(&buffer_struct) );
return hmat;
}
size_t hmat_zsize( hmat_matrix_t *hmat ) {
size_t size = 0;
hmat_zinterface.write_struct( hmat, (hmat_iostream)(&buffer_comm_size), (void *)(&size) );
hmat_zinterface.write_data( hmat, (hmat_iostream)(&buffer_comm_size), (void *)(&size) );
return size;
}
void hmat_zwrite( hmat_matrix_t *hmat, char *ptr ) {
hmat_buffer_comm_t buffer_struct = { 0, ptr };
hmat_zinterface.write_struct( hmat, (hmat_iostream)(&buffer_comm_write), (void *)(&buffer_struct) );
hmat_zinterface.write_data( hmat, (hmat_iostream)(&buffer_comm_write), (void *)(&buffer_struct) );
}
void hmat_zdestroy( hmat_matrix_t *hmat ) {
hmat_zinterface.destroy( hmat );
}
/**
*
* @file hmat.h
*
* @copyright 2009-2014 The University of Tennessee and The University of
* Tennessee Research Foundation. All rights reserved.
* @copyright 2012-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
***
*
* @brief Chameleon CPU hmat-oss function declaration
*
* @version 0.9.2
* @author Rocio Carratala-Saez
* @author Mathieu Faverge
* @date 2019-12-02
*
*/
#ifndef _coreblas_hmat_h_
#define _coreblas_hmat_h_
#include "coreblas.h"
#if !defined( CHAMELEON_USE_HMAT )
#error "This file should not be included by itself"
#endif
#include <hmat/hmat.h>
BEGIN_C_DECLS
/**
* Functions to get linearize/unlinearize hmat into/from a buffer
*/
typedef struct hmat_buffer_comm_s {
size_t offset;
char *data;
} hmat_buffer_comm_t;
// Count the size of the structure to write
static inline void
buffer_comm_size( void * buffer, size_t n, void *user_data )
{
size_t *size = (size_t *)user_data;
*size += n;
(void) buffer;
}
static inline void
buffer_comm_read(void * buffer, size_t n, void *user_data)
{
hmat_buffer_comm_t *buffer_struct = (hmat_buffer_comm_t *) user_data;
char *buffer_read = buffer_struct->data + buffer_struct->offset;
memcpy(buffer, buffer_read, n);
buffer_struct->offset += n;
}
static inline void
buffer_comm_write(void * buffer, size_t n, void *user_data)
{
hmat_buffer_comm_t *buffer_struct = (hmat_buffer_comm_t *) user_data;
char *buffer_write = buffer_struct->data + buffer_struct->offset;
memcpy(buffer_write, buffer, n);
buffer_struct->offset += n;
}
#include "coreblas/hmat_z.h"
#include "coreblas/hmat_c.h"
#include "coreblas/hmat_d.h"
#include "coreblas/hmat_s.h"
END_C_DECLS
#endif /* _coreblas_hmat_h_ */
/**
*
* @file hmat_z.h
*
* @copyright 2019-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
* @copyright 2019-2019 Universidad Jaume I. All rights reserved.
*
* @brief Chameleon CPU kernel interface from CHAM_tile_t layout to the real one.
*
* @version 1.0.0
* @author Rocio Carratala-Saez
* @author Mathieu Faverge
* @date 2019-12-02
* @precisions normal z -> c d s
*
*/
#ifndef _hmat_z_h_
#define _hmat_z_h_
HMAT_API int hmat_zgetrf( hmat_matrix_t *A );
HMAT_API int hmat_zpotrf( hmat_matrix_t *A );
HMAT_API int hmat_zgemm( char transA, char transB, void* alpha, hmat_matrix_t* A, hmat_matrix_t* B, void* beta, hmat_matrix_t* C );
HMAT_API int hmat_ztrsm( char side, char uplo, char trans, char diag, int m, int n,
void* alpha, hmat_matrix_t* A, int is_b_hmat, void* B );
HMAT_API int hmat_zgemv( char transA, void* alpha, hmat_matrix_t* A,
void* B, void* beta, void* C, int nrhs );
HMAT_API hmat_matrix_t *hmat_zread( void *buffer );
HMAT_API size_t hmat_zsize( hmat_matrix_t *hmat );
HMAT_API void hmat_zwrite( hmat_matrix_t *hmat, char *ptr );
HMAT_API void hmat_zdestroy( hmat_matrix_t *hmat );
#endif /* _hmat_z_h_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment