1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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
|
/*
-- MAGMA (version 2.9.0) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
@date January 2025
@generated from sparse/testing/testing_zblas.cpp, normal z -> d, Wed Jan 22 14:42:48 2025
@author Hartwig Anzt
*/
// includes, system
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
// includes, project
#include "magma_v2.h"
#include "magmasparse.h"
#include "magma_operators.h"
#include "testings.h"
/* ////////////////////////////////////////////////////////////////////////////
-- testing any solver
*/
int main( int argc, char** argv )
{
magma_int_t info = 0;
/* Initialize */
TESTING_CHECK( magma_init() );
magma_print_environment();
magma_queue_t queue=NULL;
magma_queue_create( 0, &queue );
magma_int_t j, n=1000000, FLOPS;
magma_int_t count = 100;
double one = MAGMA_D_MAKE( 1.0, 0.0 );
double two = MAGMA_D_MAKE( 2.0, 0.0 );
magma_d_matrix a={Magma_CSR}, ad={Magma_CSR}, bd={Magma_CSR}, cd={Magma_CSR};
TESTING_CHECK( magma_dvinit( &a, Magma_CPU, n, 1, one, queue ));
TESTING_CHECK( magma_dvinit( &bd, Magma_DEV, n, 1, two, queue ));
TESTING_CHECK( magma_dvinit( &cd, Magma_DEV, n, 1, one, queue ));
TESTING_CHECK( magma_dmtransfer( a, &ad, Magma_CPU, Magma_DEV, queue ));
real_Double_t start, end, res;
FLOPS = 2*n;
start = magma_sync_wtime( queue );
for (j=0; j < count; j++) {
res = magma_dnrm2( n, ad.dval, 1, queue );
}
end = magma_sync_wtime( queue );
printf( " > MAGMA nrm2: %.2e seconds %.2e GFLOP/s\n",
(end-start)/count, FLOPS*count/1e9/(end-start) );
FLOPS = n;
start = magma_sync_wtime( queue );
for (j=0; j < count; j++) {
magma_dscal( n, two, ad.dval, 1, queue );
}
end = magma_sync_wtime( queue );
printf( " > MAGMA scal: %.2e seconds %.2e GFLOP/s\n",
(end-start)/count, FLOPS*count/1e9/(end-start) );
FLOPS = 2*n;
start = magma_sync_wtime( queue );
for (j=0; j < count; j++) {
magma_daxpy( n, one, ad.dval, 1, bd.dval, 1, queue );
}
end = magma_sync_wtime( queue );
printf( " > MAGMA axpy: %.2e seconds %.2e GFLOP/s\n",
(end-start)/count, FLOPS*count/1e9/(end-start) );
FLOPS = n;
start = magma_sync_wtime( queue );
for (j=0; j < count; j++) {
magma_dcopy( n, bd.dval, 1, ad.dval, 1, queue );
}
end = magma_sync_wtime( queue );
printf( " > MAGMA copy: %.2e seconds %.2e GFLOP/s\n",
(end-start)/count, FLOPS*count/1e9/(end-start) );
FLOPS = 2*n;
start = magma_sync_wtime( queue );
for (j=0; j < count; j++) {
res = MAGMA_D_REAL( magma_ddot( n, ad.dval, 1, bd.dval, 1, queue ));
}
end = magma_sync_wtime( queue );
printf( " > MAGMA dotc: %.2e seconds %.2e GFLOP/s\n",
(end-start)/count, FLOPS*count/1e9/(end-start) );
printf("%% tester BLAS: ok\n");
// use res to silence compiler warnings
if ( magma_d_isnan( (double) real( res ))) {
info = -1;
}
magma_dmfree( &a, queue);
magma_dmfree(&ad, queue);
magma_dmfree(&bd, queue);
magma_dmfree(&cd, queue);
magma_queue_destroy( queue );
magma_finalize();
return info;
}
|