static krb5_error_code KRB5_CALLCONV dcc_resolve(krb5_context context, krb5_ccache *cache_out, const char *residual) { krb5_error_code ret; krb5_ccache fcc; char *primary_path = NULL, *sresidual = NULL, *dirname, *filename; *cache_out = NULL; if (*residual == ':') { /* This is a subsidiary cache within the directory. */ ret = split_path(context, residual + 1, &dirname, &filename); if (ret) return ret; ret = verify_dir(context, dirname); free(dirname); free(filename); if (ret) return ret; } else { /* This is the directory itself; resolve to the primary cache. */ ret = verify_dir(context, residual); if (ret) return ret; ret = primary_pathname(residual, &primary_path); if (ret) goto cleanup; ret = read_primary_file(context, primary_path, residual, &sresidual); if (ret == ENOENT) { /* Create an initial primary file. */ ret = write_primary_file(primary_path, "tkt"); if (ret) goto cleanup; ret = subsidiary_residual(residual, "tkt", &sresidual); if (ret) goto cleanup; } residual = sresidual; } ret = krb5_fcc_ops.resolve(context, &fcc, residual + 1); if (ret) goto cleanup; ret = make_cache(residual, fcc, cache_out); if (ret) krb5_fcc_ops.close(context, fcc); cleanup: free(primary_path); free(sresidual); return ret; }
int main(int argc,char * argv []) { setlocale(LC_ALL, ""); if(gmain.main(argc, argv)) return EXIT_FAILURE; g_log_set_default_handler(log_handler, NULL); int res = EXIT_SUCCESS; if (gmain.file_cnt > 0) { for(int i=0; i<gmain.file_cnt; ++i) { const char* file_path = gmain.files[i]; if(g_file_test(file_path, G_FILE_TEST_IS_DIR)) { g_message("Processing directory: '%s'\n", file_path); if(verify_dir(file_path)) { res = EXIT_FAILURE; g_message(verif_dir_failure, file_path); } else g_message(verif_dir_success, file_path); } else { bool dict_res = (VERIF_RESULT_CRITICAL <= stardict_verify(file_path)); if(dict_res) res = EXIT_FAILURE; if(gmain.quiet) g_print(dict_res ? verif_dict_failure : verif_dict_success, file_path); } if(!gmain.quiet) g_print("\n\n"); } } else { const std::string system_dir("/usr/share/stardict/dic"); const std::string home_dir = std::string(g_get_home_dir()) + "/.stardict/dic"; g_message("Verifying dictionaries in known directories...\n"); g_message("\nProcessing system dictionary directory: '%s'\n", system_dir.c_str()); if(verify_dir(system_dir)) { res = EXIT_FAILURE; g_message(verif_dir_failure, system_dir.c_str()); } else g_message(verif_dir_success, system_dir.c_str()); g_message("\nProcessing private user dictionary directory: '%s'\n", home_dir.c_str()); if(verify_dir(home_dir)) { res = EXIT_FAILURE; g_message(verif_dir_failure, home_dir.c_str()); } else g_message(verif_dir_success, home_dir.c_str()); } return res; }
int main(){ const char* rows[5] = {"SUM", "SUMSTR", "SUMCONSTSTR", "COPY", "COPYCONSTSTR"}; const char* cols[1] = {"n=1e9 doubles"}; const int n = 1000*1000*1000; double *a, *b; init_mem(a, b, n); double bw[5]; bw[0] = time(a, b, n, SUM); bw[1] = time(a, b, n, SUMSTR); bw[2] = time(a, b, n, SUMCONSTSTR); bw[3] = time(a, b, n, COPY); bw[4] = time(a, b, n, COPYCONSTSTR); verify_dir("DBG/"); char fname[200]; sprintf(fname, "DBG/time_sc_stride_%d.txt", STR); link_cout(fname); Table tbl; tbl.dim(5, 1); tbl.rows(rows); tbl.cols(cols); tbl.data(bw); char banner[200]; sprintf(banner, "memory bw in bytes/cycle, stride = %d\n", STR); tbl.print(banner); unlink_cout(); release_mem(a, b); }
int main(){ const char* rows[3] = {"8000", "10000", "12000"}; long dim[3] = {8000, 10000, 12000}; const char* cols[3] = {"host", "offload", "auto offload"}; enum mult_flag_enum flag[3] = {HOST, MIC, AUTO}; double data[9]; for(int i=0; i < 3; i++) for(int j=0; j < 3; j++){ std::cout<<"("<<i<<","<<j<<")"<<std::endl; data[i+j*3] = time_mult(dim[i], flag[j]); } verify_dir("DBG"); //link_cout("DBG/time_mult.txt"); Table tbl; tbl.dim(3,3); tbl.rows(rows); tbl.cols(cols); tbl.data(data); tbl.print("flops/cycle for multiplying square matrices"); //unlink_cout(); }
/* * Does a single fwd+bwd fft of size n and checks it against python. * To test fftw replace fft_mkl with fft_fftw and set flag to MKL_ALIGN. */ void test_mkl(int n, enum mkl_align_flag flag){ double *space = (double *)_mm_malloc((4*n+2)*sizeof(double), 64); double *v; switch(flag){ case MKL_ALIGN: v = space; break; case MKL_NOALIGN: v = space+1; break; } double *w = v + 2*n; for(int i=0; i < n; i++){ w[2*i] = v[2*i] = rand()*1.0/RAND_MAX - 0.5; w[2*i+1] = v[2*i+1] = rand()*1.0/RAND_MAX - 0.5; } verify_dir("DBG/"); array_out(v, 2, n, "DBG/v.dat"); fft_mkl fft(n); fft.fwd(v); array_out(v, 2, n, "DBG/vf.dat"); system("test_fft.py DBG/v.dat DBG/vf.dat"); fft.bwd(v); array_diff(v, w, 2*n); double rerror = array_max(v, 2*n)/array_max(w, 2*n); std::cout<<"\n\tfwd+bwd error in complex mkl 1D fft"<<std::endl; std::cout<<"\tn = "<<n<<std::endl; std::cout<<"\trel error = "<<rerror<<std::endl; _mm_free(space); }
int main(){ enum leib_enum flag[7] = {LEIB, PLL, PLLX, FOR, FORCHUNK, PLLFOR, SCTN}; const char* rows[7] = {"serial", "parallel", "parallelx", "for", "forchunk", "parallelfor", "section"}; const char* cols[2] = {"pi", "cycles/term"}; const int nthreads = atoi(getenv("OMP_NUM_THREADS")); std::cout<<"num of threads = "<<nthreads<<std::endl; const long n = 1l*1000*1000*1000*10; double data[14]; struct leib_struct ans; for(int i=0; i < 7; i++){ ans = time_leibniz(n, nthreads, flag[i]); data[i] = ans.pi; data[i+7] = ans.cycles/n; } Table tbl; tbl.dim(7, 2); tbl.rows(rows); tbl.cols(cols); tbl.data(data); verify_dir("DBG"); link_cout("DBG/time_leibniz.txt"); char banner[200]; sprintf(banner, "sum of %ld terms of Leibniz", n); tbl.print(banner); unlink_cout(); }
static int verify_dir(const std::string& dirname) { int res = EXIT_SUCCESS; GDir *dir = g_dir_open(dirname.c_str(), 0, NULL); if (dir) { const gchar *filename; std::string fullfilename; while ((filename = g_dir_read_name(dir))!=NULL) { fullfilename = dirname + "/" + filename; if (g_file_test(fullfilename.c_str(), G_FILE_TEST_IS_DIR)) { if(verify_dir(fullfilename)) res = EXIT_FAILURE; } else if (g_str_has_suffix(filename,".ifo")) { bool dict_res = (VERIF_RESULT_CRITICAL <= stardict_verify(fullfilename.c_str())); if(dict_res) res = EXIT_FAILURE; if(gmain.quiet) g_print(dict_res ? verif_dict_failure : verif_dict_success, fullfilename.c_str()); else g_print("\n\n"); } } g_dir_close(dir); } return res; }
int main(){ int rank, nprocs; mpi_initialize(rank, nprocs); mpi_print_name(rank); const char *rows[6] = {"1e3", "1e4", "1e5", "1e6", "1e7", "1e8"}; int nlist[6] = {1000, 1000*10, 1000*100, 1000*1000, 1000*1000*10, 1000*1000*100}; const char* cols[2] = {"cycles", "b/w"}; double data[12]; for(int i=0; i < 6; i++){ data[i] = time(rank, nprocs, nlist[i]); data[i+6] = 32.0*nlist[i]/data[i]; } if(rank == 0){//output table char fname[200]; verify_dir("DBG"); sprintf(fname, "DBG/time_cycle_NP%d.txt", nprocs); link_cout(fname); Table tbl; tbl.dim(6, 2); tbl.rows(rows); tbl.cols(cols); tbl.data(data); tbl.print(); unlink_cout(); } mpi_finalize(); }
int main(){ int dim[4] = {100, 1000, 2000, 6000}; int count[4] = {4000, 40, 10, 1}; verify_dir("DBG/"); const char* fname = "DBG/cpp-mult.txt"; link_cout(fname); for(int i=0; i < 4; i++){ timecppmult(dim[i], count[i]); } unlink_cout(); }
PyPlot::PyPlot(const char* namei, enum pipe_type pipe){ pipe_state = pipe; verify_dir("FIGS"); chdir("FIGS/"); pypipe = popen("python", "w"); assrt(pypipe != NULL); chdir(".."); assrt(strlen(namei)<25); strcpy(name, namei); state = 0; for(int i=0; i < MAX_NUM_PYPLT_CMDS; i++) cmd[i] = new char[MAX_CMD_PYPLT_LEN]; cmdnum = 0; linenum = -1; savedata = 0; sprintf(cmdstr, "import matplotlib as mpl\n"); issue_command(cmdstr); sprintf(cmdstr, "mpl.rcParams['font.size'] = 18\n"); issue_command(cmdstr); /* * change backend if PLTOFF */ if(pipe_state == PLTOFF){ sprintf(cmdstr, "mpl.use('PDF', warn = True)\n"); issue_command(cmdstr); } sprintf(cmdstr, "from matplotlib import pyplot as plt\n"); issue_command(cmdstr); sprintf(cmdstr, "from numpy import genfromtxt\n"); issue_command(cmdstr); sprintf(cmdstr, "fig = plt.figure(1)\n"); issue_command(cmdstr); sprintf(cmdstr, "ax = plt.subplot(111)\n"); issue_command(cmdstr); }
int main(){ const int nrows = 12; int nlist[nrows] = {1, 2, 4, 8, 16, 24, 32, 40, 60, 1000, 10*1000, 100*1000}; const char *rows[nrows] = {"1", "2", "4", "8", "16", "24", "32", "40", "60", "1000", "10*1000", "100*1000"}; const int ncols = 3; const char *cols[ncols] = {"min", "median", "max"}; double cyc2dram[nrows*ncols]; StatVector stats(NTRIALS); for(int i=0; i < nrows; i++){ measure_latency(nlist[i], stats); cyc2dram[i+0*nrows] = stats.min(); cyc2dram[i+1*nrows] = stats.median(); cyc2dram[i+2*nrows] = stats.max(); } verify_dir("DBG"); #ifdef MEMWALK const char* fname = "DBG/latency_memwalk.txt"; #else const char* fname = "DBG/latency_clflush.txt"; #endif link_cout(fname); Table tbl; tbl.dim(nrows, ncols); tbl.rows(rows); tbl.cols(cols); tbl.data(cyc2dram); char banner[200]; sprintf(banner, "cycles to dram, ntrials = %d, when N pages accessed", NTRIALS); tbl.print(banner); unlink_cout(); }
void generate_output(int rank, int nprocs){ std::ofstream ofile; if(rank == 0){ verify_dir("DBG"); ofile.open("DBG/unsafe1KTO100K.txt"); } for(int i=1; i <= 100; i++){ int n = i*1000/8; //num of doubles. double cycles = time_unsafe(rank, nprocs, n); if(rank == 0){ ofile<<"number of bytes xchgd: "<<n*8<<std::endl; ofile<<" cycles: "<<cycles <<std::endl<<std::endl; } } if(rank == 0) ofile.close(); }
void testlu(int n){ double *A = new double[n*n]; double *v = new double[n]; for(int i = 0; i < n; i++){ v[i] = rand()*1.0/RAND_MAX-0.5; for(int j = 0; j < n; j++) A[i+j*n] = rand()*1.0/RAND_MAX - 0.5; } verify_dir("DBG/"); array_out(A, n, n, "DBG/A.dat"); LU_Solve lu(A, n); lu.factorize(); array_out(v, n, 1, "DBG/b.dat"); lu.solve(v); array_out(v, n, 1, "DBG/x.dat"); system("test_lusolve.py DBG/A.dat DBG/b.dat DBG/x.dat"); delete[] v; delete[] A; }
gboolean conf_verify_dir(void) { return verify_dir(app.conf_dir, NULL); }
/* Set the path global variable */ int set_home_path() { memset(path, 0, sizeof(path)); return verify_dir(); }