MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
cprint.cpp File Reference
#include "common_magma.h"
Include dependency graph for cprint.cpp:

Go to the source code of this file.

Macros

#define A(i, j)   (A + i + j*lda)

Functions

static int is_devptr (void *A)
void magma_cprint (int m, int n, cuFloatComplex *A, int lda)
void magma_cprint_gpu (int m, int n, cuFloatComplex *dA, int ldda)

Macro Definition Documentation

#define A (   i,
 
)    (A + i + j*lda)

Definition at line 47 of file cprint.cpp.


Function Documentation

static int is_devptr ( void *  A)
static

Definition at line 21 of file cprint.cpp.

{
cudaError_t err;
cudaDeviceProp prop;
cudaPointerAttributes attr;
int dev;
err = cudaGetDevice( &dev );
if ( ! err ) {
err = cudaGetDeviceProperties( &prop, dev );
if ( ! err and prop.unifiedAddressing ) {
err = cudaPointerGetAttributes( &attr, A );
if ( ! err ) {
// definitely know type
return (attr.memoryType == cudaMemoryTypeDevice);
}
else if ( err == cudaErrorInvalidValue ) {
// infer as host pointer
return 0;
}
}
}
// unknown, e.g., device doesn't support unified addressing
return -1;
}

Here is the caller graph for this function:

void magma_cprint ( int  m,
int  n,
cuFloatComplex *  A,
int  lda 
)

Definition at line 52 of file cprint.cpp.

References A, is_devptr(), MAGMA_C_EQUAL, MAGMA_C_REAL, and MAGMA_C_ZERO.

{
if ( is_devptr( A ) == 1 ) {
fprintf( stderr, "ERROR: cprint called with device pointer.\n" );
exit(1);
}
cuFloatComplex c_zero = MAGMA_C_ZERO;
printf( "[\n" );
for( int i = 0; i < m; ++i ) {
for( int j = 0; j < n; ++j ) {
if ( MAGMA_C_EQUAL( *A(i,j), c_zero )) {
printf( " 0. " );
}
else {
printf( " %8.4f", MAGMA_C_REAL( *A(i,j) ));
}
}
printf( "\n" );
}
printf( "];\n" );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void magma_cprint_gpu ( int  m,
int  n,
cuFloatComplex *  dA,
int  ldda 
)

Definition at line 81 of file cprint.cpp.

References A, is_devptr(), and magma_cprint().

{
if ( is_devptr( dA ) == 0 ) {
fprintf( stderr, "ERROR: cprint_gpu called with host pointer.\n" );
exit(1);
}
int lda = m;
cuFloatComplex* A = (cuFloatComplex*) malloc( lda*n*sizeof(cuFloatComplex) );
cublasGetMatrix( m, n, sizeof(cuFloatComplex), dA, ldda, A, lda );
magma_cprint( m, n, A, lda );
free( A );
}

Here is the call graph for this function: