void overflowTest() { ups_key_t key = {}; ups_record_t rec = {}; RecnoType recno = std::numeric_limits<RecnoType>::max(); ldb()->_current_record_number = recno; recno = 0; key.flags = UPS_KEY_USER_ALLOC; key.data = &recno; key.size = sizeof(recno); REQUIRE(UPS_LIMITS_REACHED == ups_db_insert(db, 0, &key, &rec, 0)); }
int main(int argc, char *argv[]) { static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "karma", no_argument, NULL, 'k' }, { "threads", required_argument, NULL, 't' }, { "dbfile", required_argument, NULL, 'f' }, { NULL, 0, NULL, 0 } }; int nthreads = 0; const char *dbfile = DEFAULT_DB_FILE; bool karma = false; int option_index; int option; while ((option = getopt_long(argc, argv, "ht:f:k", options, &option_index)) != -1) { switch (option) { case 'h': Usage(stdout); return 0; case 't': nthreads = (int)strtoul(optarg, NULL, 10); break; case 'f': dbfile = optarg; break; case 'k': karma = true; break; default: Usage(stderr); return 1; } } int nargs = argc-optind; if (nargs < 2 || nargs > 3 || nthreads < 0) { Usage(stderr); return 1; } if (!nthreads) nthreads = util::CountCPUs() * 2; const char *outputdir = argv[optind]; const char *mediaroot = argv[optind+1]; const char *flacroot = argv[optind+2]; if (!flacroot) flacroot = ""; db::steam::Database sdb(mediadb::FIELD_COUNT); sdb.SetFieldInfo(mediadb::ID, db::steam::FIELD_INT|db::steam::FIELD_INDEXED); sdb.SetFieldInfo(mediadb::PATH, db::steam::FIELD_STRING|db::steam::FIELD_INDEXED); TRACE << "reading\n"; mediadb::ReadXML(&sdb, "db.xml"); TRACE << "scanning\n"; util::WorkerThreadPool wtp(util::WorkerThreadPool::NORMAL, nthreads); util::http::Client http_client; db::local::Database ldb(&sdb, &http_client); #if HAVE_TAGLIB db::local::FileScanner ifs(mediaroot, flacroot, &sdb, &ldb, &wtp); ifs.Scan(); TRACE << "writing\n"; FILE *f = fopen("db.xml", "wb"); mediadb::WriteXML(&sdb, 1, f); fclose(f); TRACE << "arranging\n"; WriteFIDStructure(outputdir, &sdb, karma); #endif return 0; }
void createCloseOpenCloseTest() { reopen(); uint32_t mask = UPS_RECORD_NUMBER32 | UPS_RECORD_NUMBER64; REQUIRE((ldb()->flags() & mask) != 0); }
Matrix operator * (const Matrix& A, const Matrix& B) { if (A.Clo() != B.Rlo() || A.Chi() != B.Rhi()) Matpack.Error("Matrix operator * (const Matrix&, const Matrix&): " "non conformant arguments\n"); // allocate return matrix Matrix C(A.Rlo(),A.Rhi(),B.Clo(),B.Chi()); //------------------------------------------------------------------------// // the BLAS version //------------------------------------------------------------------------// #if defined ( _MATPACK_USE_BLAS_ ) if ( LT(B) ) { // full matrix * lower triangle #ifdef DEBUG cout << "GM*LT\n"; #endif checksquare(B); // copy A to C to protect from overwriting copyvec(C.Store(),A.Store(),A.Elements()); charT side('L'), uplo('U'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,B.Store(),&ldb, C.Store(),&ldc); } else if ( UT(B) ) { // full matrix * upper triangle #ifdef DEBUG cout << "GM*UT\n"; #endif checksquare(B); // copy A to C to protect from overwriting copyvec(C.Store(),A.Store(),A.Elements()); charT side('L'), uplo('L'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,B.Store(),&ldb, C.Store(),&ldc); } else if ( LT(A) ) { // lower triangle * full matrix #ifdef DEBUG cout << "LT*GM\n"; #endif checksquare(A); // copy B to C to protect from overwriting copyvec(C.Store(),B.Store(),B.Elements()); charT side('R'), uplo('U'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(A.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,A.Store(),&ldb, C.Store(),&ldc); } else if ( UT(A) ) { // upper triangle * full matrix #ifdef DEBUG cout << "UT*GM\n"; #endif checksquare(A); // copy A to C to protect from overwriting copyvec(C.Store(),B.Store(),B.Elements()); charT side('R'), uplo('L'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(A.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,A.Store(),&ldb, C.Store(),&ldc); } else /* GM(A) and GM(B) */ { // GM*GM: full matrix * full matrix #ifdef DEBUG cout << "GM*GM\n"; #endif charT t('N'); intT m(B.Cols()), n(A.Rows()), k(B.Rows()), lda(A.Cols()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0), beta(0.0); F77NAME(dgemm)(&t,&t, &m,&n,&k, &alpha,B.Store(),&ldb, A.Store(),&lda, &beta,C.Store(),&ldc); } //------------------------------------------------------------------------// // the non-BLAS version //------------------------------------------------------------------------// #else int cl = A.cl, ch = A.ch, arl = A.rl, arh = A.rh, bcl = B.cl, bch = B.ch; // avoid call to index operator that optimizes very badely double **a = A.M, **b = B.M, **c = C.M; for (int i = arl; i <= arh; i++) { for (int j = bcl; j <= bch; j++) c[i][j] = 0.0; for (int l = cl; l <= ch; l++) { if ( a[i][l] != 0.0 ) { double temp = a[i][l]; for (int j = bcl; j <= bch; j++) c[i][j] += temp * b[l][j]; } } } #endif return C.Value(); }