本文整理汇总了C++中parse_opts函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_opts函数的具体用法?C++ parse_opts怎么用?C++ parse_opts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_opts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
/* ////////////////////////////////////////////////////////////////////////////
-- Testing csymmetrize
Code is very similar to testing_ctranspose.cpp
*/
int main( int argc, char** argv)
{
TESTING_INIT();
real_Double_t gbytes, gpu_perf, gpu_time, cpu_perf, cpu_time;
float error, work[1];
magmaFloatComplex c_neg_one = MAGMA_C_NEG_ONE;
magmaFloatComplex *h_A, *h_R;
magmaFloatComplex *d_A;
magma_int_t N, size, lda, ldda;
magma_int_t ione = 1;
magma_opts opts;
parse_opts( argc, argv, &opts );
printf(" N CPU GByte/s (sec) GPU GByte/s (sec) check\n");
printf("=====================================================\n");
for( int i = 0; i < opts.ntest; ++i ) {
for( int iter = 0; iter < opts.niter; ++iter ) {
N = opts.nsize[i];
lda = N;
ldda = ((N+31)/32)*32;
size = lda*N;
// load strictly lower triangle, save strictly upper triangle
gbytes = sizeof(magmaFloatComplex) * 1.*N*(N-1) / 1e9;
TESTING_MALLOC( h_A, magmaFloatComplex, size );
TESTING_MALLOC( h_R, magmaFloatComplex, size );
TESTING_DEVALLOC( d_A, magmaFloatComplex, ldda*N );
/* Initialize the matrix */
for( int j = 0; j < N; ++j ) {
for( int i = 0; i < N; ++i ) {
h_A[i + j*lda] = MAGMA_C_MAKE( i + j/10000., j );
}
}
/* ====================================================================
Performs operation using MAGMA
=================================================================== */
magma_csetmatrix( N, N, h_A, lda, d_A, ldda );
gpu_time = magma_sync_wtime( 0 );
//magmablas_csymmetrize( opts.uplo, N-2, d_A+1+ldda, ldda ); // inset by 1 row & col
magmablas_csymmetrize( opts.uplo, N, d_A, ldda );
gpu_time = magma_sync_wtime( 0 ) - gpu_time;
gpu_perf = gbytes / gpu_time;
/* =====================================================================
Performs operation using naive in-place algorithm
(LAPACK doesn't implement symmetrize)
=================================================================== */
cpu_time = magma_wtime();
//for( int j = 1; j < N-1; ++j ) { // inset by 1 row & col
// for( int i = 1; i < j; ++i ) {
for( int j = 0; j < N; ++j ) {
for( int i = 0; i < j; ++i ) {
if ( opts.uplo == MagmaLower ) {
h_A[i + j*lda] = MAGMA_C_CNJG( h_A[j + i*lda] );
}
else {
h_A[j + i*lda] = MAGMA_C_CNJG( h_A[i + j*lda] );
}
}
}
cpu_time = magma_wtime() - cpu_time;
cpu_perf = gbytes / cpu_time;
/* =====================================================================
Check the result
=================================================================== */
magma_cgetmatrix( N, N, d_A, ldda, h_R, lda );
blasf77_caxpy(&size, &c_neg_one, h_A, &ione, h_R, &ione);
error = lapackf77_clange("f", &N, &N, h_R, &lda, work);
printf("%5d %7.2f (%7.2f) %7.2f (%7.2f) %s\n",
(int) N, cpu_perf, cpu_time, gpu_perf, gpu_time,
(error == 0. ? "ok" : "failed") );
TESTING_FREE( h_A );
TESTING_FREE( h_R );
TESTING_DEVFREE( d_A );
}
if ( opts.niter > 1 ) {
printf( "\n" );
}
}
TESTING_FINALIZE();
return 0;
}
开发者ID:soulsheng,项目名称:magma,代码行数:96,代码来源:testing_csymmetrize.cpp
示例2: main
int main(int argc, char *argv[])
{
size_t memsize = 0; /* at first in MB, limited to 4Gb on 32 bits */
int pagesize;
int i;
int lc;
char *msg;
char *p, *bigmalloc;
int loop_count; /* limited to 16Go on 32 bits systems */
pagesize = sysconf(_SC_PAGESIZE);
if ((msg = parse_opts(argc, argv, options, help)) != (char *)NULL)
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
if (m_opt) {
memsize = (size_t) atoi(m_copt) * 1024 * 1024;
if (memsize < 1) {
tst_brkm(TBROK, cleanup, "Invalid arg for -m: %s",
m_copt);
}
}
if (r_opt)
srand(time(NULL));
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
if (!m_opt) {
/* find out by ourselves! */
memsize = get_memsize();
if (memsize < 1) {
tst_brkm(TBROK, cleanup,
"Unable to guess maxmemsize from /proc/meminfo");
}
}
/* Allocate (virtual) memory */
bigmalloc = p = malloc(memsize);
if (!p) {
tst_resm(TFAIL, "malloc - alloc of %zuMB failed",
memsize / 1024 / 1024);
cleanup();
}
/*
* Dirty all the pages, to force physical RAM allocation
* and exercise eventually the swapper
*/
tst_resm(TINFO, "touching %zuMB of malloc'ed memory (%s)",
memsize / 1024 / 1024, r_opt ? "random" : "linear");
loop_count = memsize / pagesize;
for (i = 0; i < loop_count; i++) {
if (v_opt
&& (i % (PROGRESS_LEAP * 1024 / pagesize) == 0)) {
printf(".");
fflush(stdout);
}
/*
* Make the page dirty,
* and make sure compiler won't optimize it away
* Touching more than one word per page is useless
* because of cache.
*/
*(int *)p = 0xdeadbeef ^ i;
if (r_opt) {
p = bigmalloc +
(size_t) ((double)(memsize - sizeof(int)) *
rand() / (RAND_MAX + 1.0));
} else {
p += pagesize;
}
}
if (v_opt)
printf("\n");
/* This is not mandatory (except in a loop), but it exercise mm again */
free(bigmalloc);
/*
* seems that if the malloc'ed area was bad, we'd get SEGV (or kicked
* somehow by the OOM killer?), hence we can indicate a PASS.
*/
tst_resm(TPASS, "malloc - alloc of %zuMB succeeded",
memsize / 1024 / 1024);
}
cleanup();
//.........这里部分代码省略.........
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:101,代码来源:mem01.c
示例3: main
int main(int ac, char **av)
{
int lc;
char *msg;
void check_functionality(void);
int r_val;
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup(); /* global setup */
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
/* get the name of the test dirctory */
if ((temp_dir = (getcwd(temp_dir, 0))) == NULL)
tst_brkm(TBROK, cleanup, "getcwd failed");
/*
* create a new directory and open it
*/
if ((r_val = mkdir(TEST_DIR, MODES)) == -1)
tst_brkm(TBROK, cleanup, "mkdir failed");
if ((fd = open(TEST_DIR, O_RDONLY)) == -1)
tst_brkm(TBROK, cleanup, "open of directory failed");
TEST(fchdir(fd));
if (TEST_RETURN == -1)
tst_brkm(TFAIL | TTERRNO, cleanup,
"fchdir call failed");
else {
if (STD_FUNCTIONAL_TEST)
check_functionality();
else
tst_resm(TPASS, "call succeeded");
}
/*
* clean up things in case we are looping
*/
/*
* NOTE: in case of failure here, we need to use "tst_resm()"
* and not "tst_brkm()". This is because if we get to this
* point, we have already set a PASS or FAIL for the test
* and "tst_brkm()" won't report as we might expect.
*/
/* chdir back to our temporary work directory */
if ((r_val = chdir("..")) == -1)
tst_resm(TBROK | TERRNO, "chdir failed");
if ((r_val = rmdir(TEST_DIR)) == -1)
tst_resm(TBROK | TERRNO, "rmdir failed");
free(temp_dir);
temp_dir = NULL;
}
cleanup();
tst_exit();
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:67,代码来源:fchdir01.c
示例4: main
int main(int ac, char **av)
{
int lc;
char *msg;
int ind;
int offset;
/***************************************************************
* parse standard options
***************************************************************/
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
}
/***************************************************************
* perform global setup for test
***************************************************************/
setup();
/* set the expected errnos... */
TEST_EXP_ENOS(exp_enos);
/***************************************************************
* check looping state if -c option given
***************************************************************/
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
offset = (lc % 100) * 4096; /* max size is 100 blocks */
for (ind = 0; Whence[ind] >= 0; ind++) {
/*
* Call lseek(2)
*/
TEST(lseek(Fd, (long)offset, Whence[ind]));
/* check return code */
if (TEST_RETURN == -1) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL,
"lseek(%s, %d, 0) Failed, errno=%d : %s",
Fname, offset, TEST_ERRNO,
strerror(TEST_ERRNO));
} else {
/***************************************************************
* only perform functional verification if flag set (-f not given)
***************************************************************/
if (STD_FUNCTIONAL_TEST) {
/* No Verification test, yet... */
tst_resm(TPASS,
"lseek(%s, %d, %d) returned %ld",
Fname, offset, Whence[ind],
TEST_RETURN);
} else
tst_count++;
}
}
}
/***************************************************************
* cleanup and exit
***************************************************************/
cleanup();
tst_exit();
}
开发者ID:GOEUM,项目名称:ltp,代码行数:72,代码来源:lseek01.c
示例5: main
// ----------------------------------------
int main( int argc, char** argv )
{
TESTING_INIT();
//real_Double_t t_m, t_c, t_f;
magma_int_t ione = 1;
magmaDoubleComplex *A, *B;
double diff, error;
magma_int_t ISEED[4] = {0,0,0,1};
magma_int_t m, n, k, size, maxn, ld;
magmaDoubleComplex x2_m, x2_c; // complex x for magma, cblas/fortran blas respectively
double x_m, x_c; // x for magma, cblas/fortran blas respectively
magma_opts opts;
parse_opts( argc, argv, &opts );
opts.tolerance = max( 100., opts.tolerance );
double tol = opts.tolerance * lapackf77_dlamch("E");
gTol = tol;
printf( "!! Calling these CBLAS and Fortran BLAS sometimes crashes (segfault), which !!\n"
"!! is why we use wrappers. It does not necesarily indicate a bug in MAGMA. !!\n"
"\n"
"Diff compares MAGMA wrapper to CBLAS and BLAS function; should be exactly 0.\n"
"Error compares MAGMA implementation to CBLAS and BLAS function; should be ~ machine epsilon.\n"
"\n" );
double total_diff = 0.;
double total_error = 0.;
int inc[] = { 1 }; //{ -2, -1, 1, 2 }; //{ 1 }; //{ -1, 1 };
int ninc = sizeof(inc)/sizeof(*inc);
for( int itest = 0; itest < opts.ntest; ++itest ) {
m = opts.msize[itest];
n = opts.nsize[itest];
k = opts.ksize[itest];
for( int iincx = 0; iincx < ninc; ++iincx ) {
magma_int_t incx = inc[iincx];
for( int iincy = 0; iincy < ninc; ++iincy ) {
magma_int_t incy = inc[iincy];
printf("=========================================================================\n");
printf( "m=%d, n=%d, k=%d, incx = %d, incy = %d\n",
(int) m, (int) n, (int) k, (int) incx, (int) incy );
printf( "Function MAGMA CBLAS BLAS Diff Error\n"
" msec msec msec\n" );
// allocate matrices
// over-allocate so they can be any combination of
// {m,n,k} * {abs(incx), abs(incy)} by
// {m,n,k} * {abs(incx), abs(incy)}
maxn = max( max( m, n ), k ) * max( abs(incx), abs(incy) );
ld = max( 1, maxn );
size = ld*maxn;
magma_zmalloc_pinned( &A, size ); assert( A != NULL );
magma_zmalloc_pinned( &B, size ); assert( B != NULL );
// initialize matrices
lapackf77_zlarnv( &ione, ISEED, &size, A );
lapackf77_zlarnv( &ione, ISEED, &size, B );
printf( "Level 1 BLAS ----------------------------------------------------------\n" );
// ----- test DZASUM
// get one-norm of column j of A
if ( incx > 0 && incx == incy ) { // positive, no incy
diff = 0;
error = 0;
for( int j = 0; j < k; ++j ) {
x_m = magma_cblas_dzasum( m, A(0,j), incx );
x_c = cblas_dzasum( m, A(0,j), incx );
diff += fabs( x_m - x_c );
x_c = blasf77_dzasum( &m, A(0,j), &incx );
error += fabs( (x_m - x_c) / (m*x_c) );
}
output( "dzasum", diff, error );
total_diff += diff;
total_error += error;
}
// ----- test DZNRM2
// get two-norm of column j of A
if ( incx > 0 && incx == incy ) { // positive, no incy
diff = 0;
error = 0;
for( int j = 0; j < k; ++j ) {
x_m = magma_cblas_dznrm2( m, A(0,j), incx );
x_c = cblas_dznrm2( m, A(0,j), incx );
diff += fabs( x_m - x_c );
x_c = blasf77_dznrm2( &m, A(0,j), &incx );
error += fabs( (x_m - x_c) / (m*x_c) );
//.........这里部分代码省略.........
开发者ID:XapaJIaMnu,项目名称:magma,代码行数:101,代码来源:testing_cblas_z.cpp
示例6: report_to_kerneloops
static void report_to_kerneloops(
const char *dump_dir_name,
map_string_t *settings)
{
problem_data_t *problem_data = create_problem_data_for_reporting(dump_dir_name);
if (!problem_data)
xfunc_die(); /* create_problem_data_for_reporting already emitted error msg */
const char *backtrace = problem_data_get_content_or_NULL(problem_data, FILENAME_BACKTRACE);
if (!backtrace)
error_msg_and_die("Error sending kernel oops due to missing backtrace");
const char *env = getenv("KerneloopsReporter_SubmitURL");
const char *submitURL = (env ? env : get_map_string_item_or_empty(settings, "SubmitURL"));
if (!submitURL[0])
submitURL = "http://oops.kernel.org/submitoops.php";
log(_("Submitting oops report to %s"), submitURL);
CURLcode ret = http_post_to_kerneloops_site(submitURL, backtrace);
if (ret != CURLE_OK)
error_msg_and_die("Kernel oops has not been sent due to %s", curl_easy_strerror(ret));
problem_data_free(problem_data);
/* Server replies with:
* 200 thank you for submitting the kernel oops information
* RemoteIP: 34192fd15e34bf60fac6a5f01bba04ddbd3f0558
* - no URL or bug ID apparently...
*/
struct dump_dir *dd = dd_opendir(dump_dir_name, /*flags:*/ 0);
if (dd)
{
report_result_t rr = { .label = (char *)"kerneloops" };
rr.url = (char *)submitURL;
add_reported_to_entry(dd, &rr);
dd_close(dd);
}
log("Kernel oops report was uploaded");
}
int main(int argc, char **argv)
{
abrt_init(argv);
/* I18n */
setlocale(LC_ALL, "");
#if ENABLE_NLS
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
#endif
map_string_t *settings = new_map_string();
const char *dump_dir_name = ".";
GList *conf_file = NULL;
/* Can't keep these strings/structs static: _() doesn't support that */
const char *program_usage_string = _(
"& [-v] [-c CONFFILE]... -d DIR\n"
"\n"
"Reports kernel oops to kerneloops.org (or similar) site.\n"
"\n"
"Files with names listed in $EXCLUDE_FROM_REPORT are not included\n"
"into the tarball.\n"
"\n"
"CONFFILE lines should have 'PARAM = VALUE' format.\n"
"Recognized string parameter: SubmitURL.\n"
"Parameter can be overridden via $KerneloopsReporter_SubmitURL."
);
enum {
OPT_v = 1 << 0,
OPT_d = 1 << 1,
OPT_c = 1 << 2,
};
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
OPT_STRING('d', NULL, &dump_dir_name, "DIR" , _("Problem directory")),
OPT_LIST( 'c', NULL, &conf_file , "FILE", _("Configuration file")),
OPT_END()
};
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
export_abrt_envvars(0);
while (conf_file)
{
char *fn = (char *)conf_file->data;
log_notice("Loading settings from '%s'", fn);
load_conf_file(fn, settings, /*skip key w/o values:*/ false);
log_debug("Loaded '%s'", fn);
conf_file = g_list_remove(conf_file, fn);
}
report_to_kerneloops(dump_dir_name, settings);
free_map_string(settings);
return 0;
}
开发者ID:credmon,项目名称:libreport,代码行数:100,代码来源:reporter-kerneloops.c
示例7: main
/*ARGSUSED*/
int
main(int argc, char **argv)
{
register int i, j, ok, pid;
int count, child, status, nwait;
#ifdef UCLINUX
char *msg;
if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
argv0 = argv[0];
maybe_run_child(&do_child, "dS", &id_uclinux, &maxsemstring);
#endif
prog = argv[0];
nwait = 0;
setup();
/*--------------------------------------------------------------*/
srand(getpid());
tid = -1;
for (i = 0; i < NPROCS; i++) {
do {
keyarray[i] = (key_t)rand();
if (keyarray[i] == IPC_PRIVATE) {
ok = 0;
continue;
}
ok = 1;
for (j = 0; j < i; j++) {
if (keyarray[j] == keyarray[i]) {
ok = 0;
break;
}
}
} while (ok == 0);
}
if ((signal(SIGTERM, term)) == SIG_ERR) {
tst_resm(TFAIL, "\tsignal failed. errno = %d", errno);
tst_exit();
}
for (i = 0; i < NPROCS; i++) {
if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
tst_exit();
}
if (pid == 0) {
procstat = 1;
dotest(keyarray[i]);
exit(0);
}
pidarray[i] = pid;
nwait++;
}
/*
* Wait for children to finish.
*/
count = 0;
while((child = wait(&status)) > 0) {
if (status) {
tst_resm(TFAIL, "%s[%d] Test failed. exit=0x%x", prog, child, status);
local_flag = FAILED;
}
++count;
}
/*
* Should have collected all children.
*/
if (count != nwait) {
tst_resm(TFAIL, "\tWrong # children waited on, count = %d", count);
local_flag = FAILED;
}
if (local_flag != FAILED)
tst_resm(TPASS, "semctl06 ran successfully!");
else tst_resm(TFAIL, "semctl06 failed");
/*--------------------------------------------------------------*/
/* Clean up any files created by test before call to anyfail. */
cleanup ();
return (0); /* shut lint up */
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:94,代码来源:semctl06.c
示例8: main
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
int incr; /* increment */
long nbrkpt; /* new brk point value */
long cur_brk_val; /* current size returned by sbrk */
long aft_brk_val; /* current size returned by sbrk */
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
/*
* Attempt to control how fast we get to test max size.
* Every MAX_SIZE_LC'th lc will be fastest test will reach max size.
*/
incr = (Max_brk_byte_size - Beg_brk_val) / (MAX_SIZE_LC / 2);
if ((incr * 2) < 4096) /* make sure that process will grow */
incr += 4096 / 2;
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
/*
* Determine new value to give brk
* Every even lc value, grow by 2 incr and
* every odd lc value, strink by one incr.
* If lc is equal to 3, no change, special case.
*/
cur_brk_val = (long)sbrk(0);
if (lc == 3) {
nbrkpt = cur_brk_val; /* no change, special one time case */
} else if ((lc % 2) == 0) {
/*
* grow
*/
nbrkpt = cur_brk_val + (2 * incr);
if (nbrkpt > Max_brk_byte_size)
nbrkpt = Beg_brk_val; /* start over */
} else {
/*
* shrink
*/
nbrkpt = cur_brk_val - incr;
}
/****
printf("cur_brk_val = %d, nbrkpt = %d, incr = %d, lc = %d\n",
cur_brk_val, nbrkpt, incr, lc);
****/
/*
* Call brk(2)
*/
TEST(brk((char *)nbrkpt));
/* check return code */
if (TEST_RETURN == -1) {
aft_brk_val = (long)sbrk(0);
tst_resm(TFAIL|TTERRNO,
"brk(%ld) failed (size before %ld, after %ld)",
nbrkpt, cur_brk_val, aft_brk_val);
} else {
if (STD_FUNCTIONAL_TEST) {
aft_brk_val = (long)sbrk(0);
if (aft_brk_val == nbrkpt) {
tst_resm(TPASS,
"brk(%ld) returned %ld, new size verified by sbrk",
nbrkpt, TEST_RETURN);
} else {
tst_resm(TFAIL,
"brk(%ld) returned %ld, sbrk before %ld, after %ld",
nbrkpt, TEST_RETURN,
cur_brk_val, aft_brk_val);
}
}
}
}
cleanup();
tst_exit();
}
开发者ID:joyforu,项目名称:android-ltp-ndk,代码行数:95,代码来源:brk01.c
示例9: main
int main(int ac, char **av)
{
int lc;
char *msg;
int results;
/* Disable test if the version of the kernel is less than 2.6.17 */
if (((results = tst_kvercmp(2, 6, 17)) < 0)) {
tst_resm(TWARN, "This test can only run on kernels that are ");
tst_resm(TWARN, "2.6.17 and higher");
exit(0);
}
/*
* parse standard options
*/
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
/*
* perform global setup for test
*/
setup();
/*
* check if the current filesystem is nfs
*/
if (tst_is_cwd_nfs()) {
tst_brkm(TCONF, cleanup,
"Cannot do tee on a file located on an NFS filesystem");
}
/*
* check looping state if -c option given
*/
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
/*
* Call tee_test
*/
TEST(tee_test());
/* check return code */
if (TEST_RETURN < 0) {
if (TEST_RETURN != -1) {
TEST_ERRNO = -TEST_RETURN;
}
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "tee() Failed, errno=%d : %s",
TEST_ERRNO, strerror(TEST_ERRNO));
} else {
/*
* only perform functional verification if flag set (-f not given)
*/
if (STD_FUNCTIONAL_TEST) {
/* No Verification test, yet... */
tst_resm(TPASS, "tee() returned %ld",
TEST_RETURN);
}
}
}
/*
* cleanup and exit
*/
cleanup();
return (0);
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:73,代码来源:tee01.c
示例10: main
/* ////////////////////////////////////////////////////////////////////////////
-- Testing zgesv
*/
int main(int argc, char **argv)
{
TESTING_INIT();
real_Double_t gflops, cpu_perf, cpu_time, gpu_perf, gpu_time;
double error, Rnorm, Anorm, Xnorm, *work;
magmaDoubleComplex c_one = MAGMA_Z_ONE;
magmaDoubleComplex c_neg_one = MAGMA_Z_NEG_ONE;
magmaDoubleComplex *h_A, *h_LU, *h_B, *h_X;
magma_int_t *ipiv;
magma_int_t N, nrhs, lda, ldb, info, sizeA, sizeB;
magma_int_t ione = 1;
magma_int_t ISEED[4] = {0,0,0,1};
magma_int_t status = 0;
magma_opts opts;
parse_opts( argc, argv, &opts );
double tol = opts.tolerance * lapackf77_dlamch("E");
nrhs = opts.nrhs;
printf("ngpu %d\n", (int) opts.ngpu );
printf(" N NRHS CPU Gflop/s (sec) GPU GFlop/s (sec) ||B - AX|| / N*||A||*||X||\n");
printf("================================================================================\n");
for( int itest = 0; itest < opts.ntest; ++itest ) {
for( int iter = 0; iter < opts.niter; ++iter ) {
N = opts.nsize[itest];
lda = N;
ldb = lda;
gflops = ( FLOPS_ZGETRF( N, N ) + FLOPS_ZGETRS( N, nrhs ) ) / 1e9;
TESTING_MALLOC_CPU( h_A, magmaDoubleComplex, lda*N );
TESTING_MALLOC_CPU( h_LU, magmaDoubleComplex, lda*N );
TESTING_MALLOC_CPU( h_B, magmaDoubleComplex, ldb*nrhs );
TESTING_MALLOC_CPU( h_X, magmaDoubleComplex, ldb*nrhs );
TESTING_MALLOC_CPU( work, double, N );
TESTING_MALLOC_CPU( ipiv, magma_int_t, N );
/* Initialize the matrices */
sizeA = lda*N;
sizeB = ldb*nrhs;
lapackf77_zlarnv( &ione, ISEED, &sizeA, h_A );
lapackf77_zlarnv( &ione, ISEED, &sizeB, h_B );
// copy A to LU and B to X; save A and B for residual
lapackf77_zlacpy( "F", &N, &N, h_A, &lda, h_LU, &lda );
lapackf77_zlacpy( "F", &N, &nrhs, h_B, &ldb, h_X, &ldb );
/* ====================================================================
Performs operation using MAGMA
=================================================================== */
gpu_time = magma_wtime();
magma_zgesv( N, nrhs, h_LU, lda, ipiv, h_X, ldb, opts.queues2, &info );
gpu_time = magma_wtime() - gpu_time;
gpu_perf = gflops / gpu_time;
if (info != 0)
printf("magma_zgesv returned error %d: %s.\n",
(int) info, magma_strerror( info ));
//=====================================================================
// Residual
//=====================================================================
Anorm = lapackf77_zlange("I", &N, &N, h_A, &lda, work);
Xnorm = lapackf77_zlange("I", &N, &nrhs, h_X, &ldb, work);
blasf77_zgemm( MagmaNoTransStr, MagmaNoTransStr, &N, &nrhs, &N,
&c_one, h_A, &lda,
h_X, &ldb,
&c_neg_one, h_B, &ldb);
Rnorm = lapackf77_zlange("I", &N, &nrhs, h_B, &ldb, work);
error = Rnorm/(N*Anorm*Xnorm);
status += ! (error < tol);
/* ====================================================================
Performs operation using LAPACK
=================================================================== */
if ( opts.lapack ) {
cpu_time = magma_wtime();
lapackf77_zgesv( &N, &nrhs, h_A, &lda, ipiv, h_B, &ldb, &info );
cpu_time = magma_wtime() - cpu_time;
cpu_perf = gflops / cpu_time;
if (info != 0)
printf("lapackf77_zgesv returned error %d: %s.\n",
(int) info, magma_strerror( info ));
printf( "%5d %5d %7.2f (%7.2f) %7.2f (%7.2f) %8.2e %s\n",
(int) N, (int) nrhs, cpu_perf, cpu_time, gpu_perf, gpu_time,
error, (error < tol ? "ok" : "failed"));
}
else {
printf( "%5d %5d --- ( --- ) %7.2f (%7.2f) %8.2e %s\n",
(int) N, (int) nrhs, gpu_perf, gpu_time,
error, (error < tol ? "ok" : "failed"));
}
//.........这里部分代码省略.........
开发者ID:kjbartel,项目名称:clmagma,代码行数:101,代码来源:testing_zgesv.cpp
示例11: main
/* ////////////////////////////////////////////////////////////////////////////
-- Testing cunmqr
*/
int main( int argc, char** argv )
{
TESTING_INIT();
real_Double_t gflops, gpu_perf, gpu_time, cpu_perf, cpu_time;
float error, work[1];
magmaFloatComplex c_neg_one = MAGMA_C_NEG_ONE;
magma_int_t ione = 1;
magma_int_t mm, m, n, k, size, info;
magma_int_t ISEED[4] = {0,0,0,1};
magma_int_t nb, ldc, lda, lwork, lwork_max;
magmaFloatComplex *C, *R, *A, *W, *tau;
magma_int_t status = 0;
magma_opts opts;
parse_opts( argc, argv, &opts );
// need slightly looser bound (60*eps instead of 30*eps) for some tests
opts.tolerance = max( 60., opts.tolerance );
float tol = opts.tolerance * lapackf77_slamch("E");
// test all combinations of input parameters
magma_side_t side [] = { MagmaLeft, MagmaRight };
magma_trans_t trans[] = { MagmaConjTrans, MagmaNoTrans };
printf(" M N K side trans CPU GFlop/s (sec) GPU GFlop/s (sec) ||R||_F / ||QC||_F\n");
printf("===============================================================================================\n");
for( int itest = 0; itest < opts.ntest; ++itest ) {
for( int iside = 0; iside < 2; ++iside ) {
for( int itran = 0; itran < 2; ++itran ) {
for( int iter = 0; iter < opts.niter; ++iter ) {
m = opts.msize[itest];
n = opts.nsize[itest];
k = opts.ksize[itest];
nb = magma_get_cgeqrf_nb( m );
ldc = m;
// A is m x k (left) or n x k (right)
mm = (side[iside] == MagmaLeft ? m : n);
lda = mm;
gflops = FLOPS_CUNMQR( m, n, k, side[iside] ) / 1e9;
if ( side[iside] == MagmaLeft && m < k ) {
printf( "%5d %5d %5d %4c %5c skipping because side=left and m < k\n",
(int) m, (int) n, (int) k,
lapacke_side_const( side[iside] ),
lapacke_trans_const( trans[itran] ) );
continue;
}
if ( side[iside] == MagmaRight && n < k ) {
printf( "%5d %5d %5d %4c %5c skipping because side=right and n < k\n",
(int) m, (int) n, (int) k,
lapacke_side_const( side[iside] ),
lapacke_trans_const( trans[itran] ) );
continue;
}
// need at least 2*nb*nb for geqrf
lwork_max = max( max( m*nb, n*nb ), 2*nb*nb );
TESTING_MALLOC_CPU( C, magmaFloatComplex, ldc*n );
TESTING_MALLOC_CPU( R, magmaFloatComplex, ldc*n );
TESTING_MALLOC_CPU( A, magmaFloatComplex, lda*k );
TESTING_MALLOC_CPU( W, magmaFloatComplex, lwork_max );
TESTING_MALLOC_CPU( tau, magmaFloatComplex, k );
// C is full, m x n
size = ldc*n;
lapackf77_clarnv( &ione, ISEED, &size, C );
lapackf77_clacpy( "Full", &m, &n, C, &ldc, R, &ldc );
size = lda*k;
lapackf77_clarnv( &ione, ISEED, &size, A );
// compute QR factorization to get Householder vectors in A, tau
magma_cgeqrf( mm, k, A, lda, tau, W, lwork_max, &info );
if (info != 0)
printf("magma_cgeqrf returned error %d: %s.\n",
(int) info, magma_strerror( info ));
/* =====================================================================
Performs operation using LAPACK
=================================================================== */
cpu_time = magma_wtime();
lapackf77_cunmqr( lapack_side_const( side[iside] ), lapack_trans_const( trans[itran] ),
&m, &n, &k,
A, &lda, tau, C, &ldc, W, &lwork_max, &info );
cpu_time = magma_wtime() - cpu_time;
cpu_perf = gflops / cpu_time;
if (info != 0)
printf("lapackf77_cunmqr returned error %d: %s.\n",
(int) info, magma_strerror( info ));
/* ====================================================================
Performs operation using MAGMA
=================================================================== */
// query for workspace size
lwork = -1;
//.........这里部分代码省略.........
开发者ID:EmergentOrder,项目名称:magma,代码行数:101,代码来源:testing_cunmqr.cpp
示例12: main
/* ////////////////////////////////////////////////////////////////////////////
-- Testing zhetrd_he2hb
*/
int main( int argc, char** argv)
{
TESTING_INIT_MGPU();
real_Double_t gflops, gpu_time, gpu_perf;
magmaDoubleComplex *h_A, *h_R, *h_work;
magmaDoubleComplex *tau;
double *D, *E;
magma_int_t N, n2, lda, ldda, lwork, ldt, info, nstream;
magma_int_t ione = 1;
magma_int_t ISEED[4] = {0,0,0,1};
magma_int_t status = 0;
// TODO add these options to parse_opts
magma_int_t NE = 0;
magma_int_t distblk = 0;
magma_opts opts;
parse_opts( argc, argv, &opts );
magma_int_t WANTZ = (opts.jobz == MagmaVec);
double tol = opts.tolerance * lapackf77_dlamch("E");
if (opts.nb == 0)
opts.nb = 64; //magma_get_zhetrd_he2hb_nb(N);
if (NE < 1)
NE = N; //64; //magma_get_zhetrd_he2hb_nb(N);
nstream = max(3, opts.ngpu+2);
magma_queue_t streams[MagmaMaxGPUs][20];
magmaDoubleComplex *da[MagmaMaxGPUs], *dT1[MagmaMaxGPUs];
if ((distblk == 0) || (distblk < opts.nb))
distblk = max(256, opts.nb);
printf("voici ngpu %d distblk %d NB %d nstream %d\n ",
(int) opts.ngpu, (int) distblk, (int) opts.nb, (int) nstream);
for( magma_int_t dev = 0; dev < opts.ngpu; ++dev ) {
magma_setdevice( dev );
for( int i = 0; i < nstream; ++i ) {
magma_queue_create( &streams[dev][i] );
}
}
magma_setdevice( 0 );
for( int itest = 0; itest < opts.ntest; ++itest ) {
for( int iter = 0; iter < opts.niter; ++iter ) {
N = opts.nsize[itest];
lda = N;
ldt = N;
ldda = ((N+31)/32)*32;
n2 = N*lda;
/* We suppose the magma NB is bigger than lapack NB */
lwork = N*opts.nb;
//gflops = ....?
/* Allocate host memory for the matrix */
TESTING_MALLOC_CPU( tau, magmaDoubleComplex, N-1 );
TESTING_MALLOC_PIN( h_A, magmaDoubleComplex, lda*N );
TESTING_MALLOC_PIN( h_R, magmaDoubleComplex, lda*N );
TESTING_MALLOC_PIN( h_work, magmaDoubleComplex, lwork );
TESTING_MALLOC_PIN( D, double, N );
TESTING_MALLOC_PIN( E, double, N );
for( magma_int_t dev = 0; dev < opts.ngpu; ++dev ) {
magma_int_t mlocal = ((N / distblk) / opts.ngpu + 1) * distblk;
magma_setdevice( dev );
TESTING_MALLOC_DEV( da[dev], magmaDoubleComplex, ldda*mlocal );
TESTING_MALLOC_DEV( dT1[dev], magmaDoubleComplex, N*opts.nb );
}
/* ====================================================================
Initialize the matrix
=================================================================== */
lapackf77_zlarnv( &ione, ISEED, &n2, h_A );
magma_zmake_hermitian( N, h_A, lda );
lapackf77_zlacpy( MagmaUpperLowerStr, &N, &N, h_A, &lda, h_R, &lda );
/* ====================================================================
Performs operation using MAGMA
=================================================================== */
/* Copy the matrix to the GPU */
magma_zsetmatrix_1D_col_bcyclic( N, N, h_R, lda, da, ldda, opts.ngpu, distblk);
//magmaDoubleComplex *dabis;
//TESTING_MALLOC_DEV( dabis, magmaDoubleComplex, ldda*N );
//magma_zsetmatrix(N, N, h_R, lda, dabis, ldda);
for (int count=0; count < 1; ++count) {
magma_setdevice(0);
gpu_time = magma_wtime();
if (opts.version == 30) {
magma_zhetrd_he2hb_mgpu_spec(
opts.uplo, N, opts.nb, h_R, lda, tau, h_work, lwork,
da, ldda, dT1, opts.nb, opts.ngpu, distblk,
streams, nstream, opts.nthread, &info);
} else {
//.........这里部分代码省略.........
开发者ID:EmergentOrder,项目名称:magma,代码行数:101,代码来源:testing_zhetrd_he2hb_mgpu.cpp
示例13: main
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
int status;
/***************************************************************
* parse standard options
***************************************************************/
if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *)NULL) {
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
tst_exit();
}
#ifdef UCLINUX
maybe_run_child(&do_child, "");
#endif
/***************************************************************
* perform global setup for test
***************************************************************/
setup();
/***************************************************************
* check looping state if -c option given
***************************************************************/
for (lc = 0; TEST_LOOPING(lc); lc++) {
/* reset Tst_count in case we are looping. */
Tst_count = 0;
/* make a child process so we can kill it */
/* If we cannot fork => we cannot test kill, so break and exit */
if ((fork_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup,
"fork() Failure. errno=%d : %s",
errno, strerror(errno));
}
if (fork_pid == 0) {
/* CHILD */
#ifdef UCLINUX
if (self_exec(av[0], "") < 0) {
tst_brkm(TBROK, cleanup,
"self_exec of child failed");
}
#else
do_child();
#endif
}
/* PARENT */
/*
* Call kill(2)
*/
TEST(kill(fork_pid, SIGKILL));
/* check return code */
if (TEST_RETURN == -1) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL,
"kill(%d, SIGKILL) Failed, errno=%d : %s",
fork_pid, TEST_ERRNO, strerror(TEST_ERRNO));
} else {
/***************************************************************
* only perform functional verification if flag set (-f not given)
***************************************************************/
if (STD_FUNCTIONAL_TEST) {
/* No Verification test, yet... */
tst_resm(TPASS, "kill(%d, SIGKILL) returned %ld",
fork_pid, TEST_RETURN);
}
}
/*
* wait for process to cleanup zombies.
*
*/
waitpid(0, &status, WNOHANG);
} /* End for TEST_LOOPING */
/***************************************************************
* cleanup and exit
***************************************************************/
cleanup();
return 0;
} /* End main */
开发者ID:ystk,项目名称:debian-ltp,代码行数:88,代码来源:kill09.c
示例14: main
/* ////////////////////////////////////////////////////////////////////////////
-- Testing cungqr
*/
int main( int argc, char** argv )
{
TESTING_INIT();
real_Double_t gflops, gpu_perf, gpu_time, cpu_perf, cpu_time;
float Anorm, error, work[1];
magmaFloatComplex c_neg_one = MAGMA_C_NEG_ONE;
magmaFloatComplex *hA, *hR, *tau, *h_work;
magmaFloatComplex_ptr dA, dT;
magma_int_t m, n, k;
magma_int_t n2, lda, ldda, lwork, min_mn, nb, info;
magma_int_t ione = 1;
magma_int_t ISEED[4] = {0,0,0,1};
magma_int_t status = 0;
magma_opts opts;
parse_opts( argc, argv, &opts );
float tol = opts.tolerance * lapackf77_slamch("E");
opts.lapack |= opts.check; // check (-c) implies lapack (-l)
printf("Running version %d; available are (specified through --version num):\n",
(int) opts.version);
printf("1 - uses precomputed clarft matrices (default)\n");
printf("2 - recomputes the clarft matrices on the fly\n\n");
printf(" m n k CPU GFlop/s (sec) GPU GFlop/s (sec) ||R|| / ||A||\n");
printf("=========================================================================\n");
for( int itest = 0; itest < opts.ntest; ++itest ) {
for( int iter = 0; iter < opts.niter; ++iter ) {
m = opts.msize[itest];
n = opts.nsize[itest];
k = opts.ksize[itest];
if ( m < n || n < k ) {
printf( "%5d %5d %5d skipping because m < n or n < k\n", (int) m, (int) n, (int) k );
continue;
}
lda = m;
ldda = ((m + 31)/32)*32;
n2 = lda*n;
min_mn = min(m, n);
nb = magma_get_cgeqrf_nb( m );
lwork = (m + 2*n+nb)*nb;
gflops = FLOPS_CUNGQR( m, n, k ) / 1e9;
TESTING_MALLOC_PIN( h_work, magmaFloatComplex, lwork );
TESTING_MALLOC_PIN( hR, magmaFloatComplex, lda*n );
TESTING_MALLOC_CPU( hA, magmaFloatComplex, lda*n );
TESTING_MALLOC_CPU( tau, magmaFloatComplex, min_mn );
TESTING_MALLOC_DEV( dA, magmaFloatComplex, ldda*n );
TESTING_MALLOC_DEV( dT, magmaFloatComplex, ( 2*min_mn + ((n + 31)/32)*32 )*nb );
lapackf77_clarnv( &ione, ISEED, &n2, hA );
lapackf77_clacpy( MagmaFullStr, &m, &n, hA, &lda, hR, &lda );
Anorm = lapackf77_clange("f", &m, &n, hA, &lda, work );
/* ====================================================================
Performs operation using MAGMA
=================================================================== */
// first, get QR factors in both hA and hR
// okay that magma_cgeqrf_gpu has special structure for R; R isn't used here.
magma_csetmatrix( m, n, hA, lda, dA, ldda );
magma_cgeqrf_gpu( m, n, dA, ldda, tau, dT, &info );
if (info != 0)
printf("magma_cgeqrf_gpu returned error %d: %s.\n",
(int) info, magma_strerror( info ));
magma_cgetmatrix( m, n, dA, ldda, hA, lda );
lapackf77_clacpy( MagmaFullStr, &m, &n, hA, &lda, hR, &lda );
gpu_time = magma_wtime();
if (opts.version == 1)
magma_cungqr( m, n, k, hR, lda, tau, dT, nb, &info );
else
magma_cungqr2(m, n, k, hR, lda, tau, &info );
gpu_time = magma_wtime() - gpu_time;
gpu_perf = gflops / gpu_time;
if (info != 0)
printf("magma_cungqr_gpu returned error %d: %s.\n",
(int) info, magma_strerror( info ));
/* =====================================================================
Performs operation using LAPACK
=================================================================== */
if ( opts.lapack ) {
cpu_time = magma_wtime();
lapackf77_cungqr( &m, &n, &k, hA, &lda, tau, h_work, &lwork, &info );
cpu_time = magma_wtime() - cpu_time;
cpu_perf = gflops / cpu_time;
if (info != 0)
printf("lapackf77_cungqr returned error %d: %s.\n",
(int) info, magma_strerror( info ));
// compute relative error |R|/|A| := |Q_magma - Q_lapack|/|A|
//.........这里部分代码省略.........
开发者ID:cjy7117,
|
请发表评论