int main(int argc, const char *argv[]) { iter_t iter; const char *fname = NULL; hid_t fid; struct handler_t *hand; H5F_info_t finfo; /* Disable error reporting */ H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* Initialize h5tools lib */ h5tools_init(); hand = parse_command_line (argc, argv); if(!hand) { error_msg(progname, "unable to parse command line arguments \n"); leave(EXIT_FAILURE); } /* end if */ fname = argv[opt_ind]; printf("Filename: %s\n", fname); fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); if(fid < 0) { error_msg(progname, "unable to open file \"%s\"\n", fname); leave(EXIT_FAILURE); } /* end if */ /* Initialize iter structure */ iter_init(&iter, fid); /* Get storge info for SOHM's btree/list/heap and superblock extension */ if(H5Fget_info(fid, &finfo) < 0) warn_msg(progname, "Unable to retrieve SOHM info\n"); else { iter.super_ext_size = finfo.super_ext_size; iter.SM_hdr_storage_size = finfo.sohm.hdr_size; iter.SM_index_storage_size = finfo.sohm.msgs_info.index_size; iter.SM_heap_storage_size = finfo.sohm.msgs_info.heap_size; } /* end else */ /* Walk the objects or all file */ if(display_object) { unsigned u; u = 0; while(hand[u].obj) { if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg(progname, "Unable to traverse object \"%s\"\n", hand[u].obj); else print_statistics(hand[u].obj, &iter); u++; } /* end while */ } /* end if */ else { if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0) warn_msg(progname, "Unable to traverse objects/links in file \"%s\"\n", fname); else print_statistics("/", &iter); } /* end else */ if (hand) free(hand); if(H5Fclose(fid) < 0) { error_msg(progname, "unable to close file \"%s\"\n", fname); leave(EXIT_FAILURE); } leave(EXIT_SUCCESS); }
main(int argc, char *argv[]) { /* * Purpose * ======= * * The driver program CLINSOLX2. * * This example illustrates how to use CGSSVX to solve systems repeatedly * with the same sparsity pattern of matrix A. * In this case, the column permutation vector perm_c is computed once. * The following data structures will be reused in the subsequent call to * CGSSVX: perm_c, etree * */ char equed[1]; yes_no_t equil; trans_t trans; SuperMatrix A, A1, L, U; SuperMatrix B, B1, X; NCformat *Astore; NCformat *Ustore; SCformat *Lstore; complex *a, *a1; int *asub, *xa, *asub1, *xa1; int *perm_r; /* row permutations from partial pivoting */ int *perm_c; /* column permutation vector */ int *etree; void *work; int info, lwork, nrhs, ldx; int i, j, m, n, nnz; complex *rhsb, *rhsb1, *rhsx, *xact; float *R, *C; float *ferr, *berr; float u, rpg, rcond; mem_usage_t mem_usage; superlu_options_t options; SuperLUStat_t stat; extern void parse_command_line(); #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif /* Defaults */ lwork = 0; nrhs = 1; equil = YES; u = 1.0; trans = NOTRANS; /* Set the default input options: options.Fact = DOFACT; options.Equil = YES; options.ColPerm = COLAMD; options.DiagPivotThresh = 1.0; options.Trans = NOTRANS; options.IterRefine = NOREFINE; options.SymmetricMode = NO; options.PivotGrowth = NO; options.ConditionNumber = NO; options.PrintStat = YES; */ set_default_options(&options); /* Can use command line input to modify the defaults. */ parse_command_line(argc, argv, &lwork, &u, &equil, &trans); options.Equil = equil; options.DiagPivotThresh = u; options.Trans = trans; if ( lwork > 0 ) { work = SUPERLU_MALLOC(lwork); if ( !work ) { ABORT("DLINSOLX: cannot allocate work[]"); } } /* Read matrix A from a file in Harwell-Boeing format.*/ creadhb(&m, &n, &nnz, &a, &asub, &xa); if ( !(a1 = complexMalloc(nnz)) ) ABORT("Malloc fails for a1[]."); if ( !(asub1 = intMalloc(nnz)) ) ABORT("Malloc fails for asub1[]."); if ( !(xa1 = intMalloc(n+1)) ) ABORT("Malloc fails for xa1[]."); for (i = 0; i < nnz; ++i) { a1[i] = a[i]; asub1[i] = asub[i]; } for (i = 0; i < n+1; ++i) xa1[i] = xa[i]; cCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_C, SLU_GE); Astore = A.Store; printf("Dimension %dx%d; # nonzeros %d\n", A.nrow, A.ncol, Astore->nnz); if ( !(rhsb = complexMalloc(m * nrhs)) ) ABORT("Malloc fails for rhsb[]."); if ( !(rhsb1 = complexMalloc(m * nrhs)) ) ABORT("Malloc fails for rhsb1[]."); if ( !(rhsx = complexMalloc(m * nrhs)) ) ABORT("Malloc fails for rhsx[]."); cCreate_Dense_Matrix(&B, m, nrhs, rhsb, m, SLU_DN, SLU_C, SLU_GE); cCreate_Dense_Matrix(&X, m, nrhs, rhsx, m, SLU_DN, SLU_C, SLU_GE); xact = complexMalloc(n * nrhs); ldx = n; cGenXtrue(n, nrhs, xact, ldx); cFillRHS(trans, nrhs, xact, ldx, &A, &B); for (j = 0; j < nrhs; ++j) for (i = 0; i < m; ++i) rhsb1[i+j*m] = rhsb[i+j*m]; if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); if ( !(perm_r = intMalloc(m)) ) ABORT("Malloc fails for perm_r[]."); if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); if ( !(R = (float *) SUPERLU_MALLOC(A.nrow * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for R[]."); if ( !(C = (float *) SUPERLU_MALLOC(A.ncol * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for C[]."); if ( !(ferr = (float *) SUPERLU_MALLOC(nrhs * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for ferr[]."); if ( !(berr = (float *) SUPERLU_MALLOC(nrhs * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for berr[]."); /* Initialize the statistics variables. */ StatInit(&stat); /* ------------------------------------------------------------ WE SOLVE THE LINEAR SYSTEM FOR THE FIRST TIME: AX = B ------------------------------------------------------------*/ cgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); printf("First system: cgssvx() returns info %d\n", info); if ( info == 0 || info == n+1 ) { /* This is how you could access the solution matrix. */ complex *sol = (complex*) ((DNformat*) X.Store)->nzval; if ( options.PivotGrowth ) printf("Recip. pivot growth = %e\n", rpg); if ( options.ConditionNumber ) printf("Recip. condition number = %e\n", rcond); Lstore = (SCformat *) L.Store; Ustore = (NCformat *) U.Store; printf("No of nonzeros in factor L = %d\n", Lstore->nnz); printf("No of nonzeros in factor U = %d\n", Ustore->nnz); printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n); printf("FILL ratio = %.1f\n", (float)(Lstore->nnz + Ustore->nnz - n)/nnz); printf("L\\U MB %.3f\ttotal MB needed %.3f\n", mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); if ( options.IterRefine ) { printf("Iterative Refinement:\n"); printf("%8s%8s%16s%16s\n", "rhs", "Steps", "FERR", "BERR"); for (i = 0; i < nrhs; ++i) printf("%8d%8d%16e%16e\n", i+1, stat.RefineSteps, ferr[i], berr[i]); } fflush(stdout); } else if ( info > 0 && lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); } if ( options.PrintStat ) StatPrint(&stat); StatFree(&stat); Destroy_CompCol_Matrix(&A); Destroy_Dense_Matrix(&B); if ( lwork >= 0 ) { /* Deallocate storage associated with L and U. */ Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } /* ------------------------------------------------------------ NOW WE SOLVE ANOTHER LINEAR SYSTEM: A1*X = B1 ONLY THE SPARSITY PATTERN OF A1 IS THE SAME AS THAT OF A. ------------------------------------------------------------*/ options.Fact = SamePattern; StatInit(&stat); /* Initialize the statistics variables. */ cCreate_CompCol_Matrix(&A1, m, n, nnz, a1, asub1, xa1, SLU_NC, SLU_C, SLU_GE); cCreate_Dense_Matrix(&B1, m, nrhs, rhsb1, m, SLU_DN, SLU_C, SLU_GE); cgssvx(&options, &A1, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B1, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); printf("\nSecond system: cgssvx() returns info %d\n", info); if ( info == 0 || info == n+1 ) { /* This is how you could access the solution matrix. */ complex *sol = (complex*) ((DNformat*) X.Store)->nzval; if ( options.PivotGrowth ) printf("Recip. pivot growth = %e\n", rpg); if ( options.ConditionNumber ) printf("Recip. condition number = %e\n", rcond); Lstore = (SCformat *) L.Store; Ustore = (NCformat *) U.Store; printf("No of nonzeros in factor L = %d\n", Lstore->nnz); printf("No of nonzeros in factor U = %d\n", Ustore->nnz); printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n); printf("L\\U MB %.3f\ttotal MB needed %.3f\n", mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); if ( options.IterRefine ) { printf("Iterative Refinement:\n"); printf("%8s%8s%16s%16s\n", "rhs", "Steps", "FERR", "BERR"); for (i = 0; i < nrhs; ++i) printf("%8d%8d%16e%16e\n", i+1, stat.RefineSteps, ferr[i], berr[i]); } fflush(stdout); } else if ( info > 0 && lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); } if ( options.PrintStat ) StatPrint(&stat); StatFree(&stat); SUPERLU_FREE (xact); SUPERLU_FREE (etree); SUPERLU_FREE (perm_r); SUPERLU_FREE (perm_c); SUPERLU_FREE (R); SUPERLU_FREE (C); SUPERLU_FREE (ferr); SUPERLU_FREE (berr); Destroy_CompCol_Matrix(&A1); Destroy_Dense_Matrix(&B1); Destroy_Dense_Matrix(&X); if ( lwork == 0 ) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } else if ( lwork > 0 ) { SUPERLU_FREE(work); } #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Exit main()"); #endif }
int main( int argc, char *argv[] ) { DFBResult ret; /* Initialize DirectFB including command line parsing. */ ret = DirectFBInit( &argc, &argv ); if (ret) { D_DERROR( ret, "Tools/Input: DirectFBInit() failed!\n" ); goto error; } /* Parse the command line. */ if (!parse_command_line( argc, argv )) goto error; /* Create the super interface. */ ret = DirectFBCreate( &dfb ); if (ret) { D_DERROR( ret, "Tools/Input: DirectFBCreate() failed!\n" ); goto error; } /* Get the input device. */ ret = dfb->GetInputDevice( dfb, id, &device ); if (ret) { if (ret == DFB_IDNOTFOUND) fprintf (stderr, "\nUnknown device id, check 'dfbinfo' for valid values.\n\n"); else D_DERROR( ret, "Tools/Input: IDirectFB::GetInputDevice() failed!\n" ); goto error; } /* Get a description of the device. */ ret = device->GetDescription( device, &desc ); if (ret) { D_DERROR( ret, "Tools/Input: IDirectFBInputDevice::GetDescription() failed!\n" ); goto error; } /* Reload the keymap. FIXME: Make public API? */ if (reload) { ret = dfb_input_device_reload_keymap( dfb_input_device_at( id ) ); if (ret) { D_DERROR( ret, "Tools/Input: Reloading the keymap failed!\n" ); goto error; } } /* Dump the keymap. */ if (dump) { int i; printf( "\n" ); for (i=desc.min_keycode; i<=desc.max_keycode; i++) { DFBInputDeviceKeymapEntry entry; ret = device->GetKeymapEntry( device, i, &entry ); if (ret) { D_DERROR( ret, "Tools/Input: IDirectFBInputDevice::GetKeymapEntry( %d ) failed!\n", i ); goto error; } printf( "%3d: %-16s %-16s %-16s %-16s\n", i, symbol_name(entry.symbols[DIKSI_BASE]), symbol_name(entry.symbols[DIKSI_BASE_SHIFT]), symbol_name(entry.symbols[DIKSI_ALT]), symbol_name(entry.symbols[DIKSI_ALT_SHIFT]) ); } printf( "\n" ); } error: /* Release the device. */ if (device) device->Release( device ); /* Release the super interface. */ if (dfb) dfb->Release( dfb ); return ret; }
int main(int argc, char *argv[]) { int r = 255; int wrote_pid_file = 0; avahi_set_log_function(log_function); init_rand_seed(); avahi_server_config_init(&config.server_config); config.command = DAEMON_RUN; config.daemonize = 0; config.config_file = NULL; #ifdef HAVE_DBUS config.enable_dbus = 1; config.fail_on_missing_dbus = 1; config.n_clients_max = 0; config.n_objects_per_client_max = 0; config.n_entries_per_entry_group_max = 0; #endif config.drop_root = 1; config.set_rlimits = 1; #ifdef ENABLE_CHROOT config.use_chroot = 1; #endif config.modify_proc_title = 1; config.disable_user_service_publishing = 0; config.publish_dns_servers = NULL; config.publish_resolv_conf = 0; config.use_syslog = 0; config.debug = 0; config.rlimit_as_set = 0; config.rlimit_core_set = 0; config.rlimit_data_set = 0; config.rlimit_fsize_set = 0; config.rlimit_nofile_set = 0; config.rlimit_stack_set = 0; #ifdef RLIMIT_NPROC config.rlimit_nproc_set = 0; #endif if ((argv0 = strrchr(argv[0], '/'))) argv0 = avahi_strdup(argv0 + 1); else argv0 = avahi_strdup(argv[0]); daemon_pid_file_ident = (const char *) argv0; daemon_log_ident = (char*) argv0; daemon_pid_file_proc = pid_file_proc; if (parse_command_line(&config, argc, argv) < 0) goto finish; if (config.modify_proc_title) avahi_init_proc_title(argc, argv); #ifdef ENABLE_CHROOT config.use_chroot = config.use_chroot && config.drop_root; #endif if (config.command == DAEMON_HELP) { help(stdout); r = 0; } else if (config.command == DAEMON_VERSION) { printf("%s "PACKAGE_VERSION"\n", argv0); r = 0; } else if (config.command == DAEMON_KILL) { if (daemon_pid_file_kill_wait(SIGTERM, 5) < 0) { avahi_log_warn("Failed to kill daemon: %s", strerror(errno)); goto finish; } r = 0; } else if (config.command == DAEMON_RELOAD) { if (daemon_pid_file_kill(SIGHUP) < 0) { avahi_log_warn("Failed to kill daemon: %s", strerror(errno)); goto finish; } r = 0; } else if (config.command == DAEMON_CHECK) r = (daemon_pid_file_is_running() >= 0) ? 0 : 1; else if (config.command == DAEMON_RUN) { pid_t pid; if (getuid() != 0 && config.drop_root) { avahi_log_error("This program is intended to be run as root."); goto finish; } if ((pid = daemon_pid_file_is_running()) >= 0) { avahi_log_error("Daemon already running on PID %u", pid); goto finish; } if (load_config_file(&config) < 0) goto finish; if (config.daemonize) { daemon_retval_init(); if ((pid = daemon_fork()) < 0) goto finish; else if (pid != 0) { int ret; /** Parent **/ if ((ret = daemon_retval_wait(20)) < 0) { avahi_log_error("Could not receive return value from daemon process."); goto finish; } r = ret; goto finish; } /* Child */ } if (config.use_syslog || config.daemonize) daemon_log_use = DAEMON_LOG_SYSLOG; if (sd_listen_fds(0) <= 0) if (daemon_close_all(-1) < 0) avahi_log_warn("Failed to close all remaining file descriptors: %s", strerror(errno)); daemon_reset_sigs(-1); daemon_unblock_sigs(-1); if (make_runtime_dir() < 0) goto finish; if (config.drop_root) { #ifdef ENABLE_CHROOT if (config.use_chroot) if (avahi_caps_reduce() < 0) goto finish; #endif if (drop_root() < 0) goto finish; #ifdef ENABLE_CHROOT if (config.use_chroot) if (avahi_caps_reduce2() < 0) goto finish; #endif } if (daemon_pid_file_create() < 0) { avahi_log_error("Failed to create PID file: %s", strerror(errno)); if (config.daemonize) daemon_retval_send(1); goto finish; } else wrote_pid_file = 1; if (config.set_rlimits) enforce_rlimits(); chdir("/"); #ifdef ENABLE_CHROOT if (config.drop_root && config.use_chroot) if (avahi_chroot_helper_start(argv0) < 0) { avahi_log_error("failed to start chroot() helper daemon."); goto finish; } #endif avahi_log_info("%s "PACKAGE_VERSION" starting up.", argv0); sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" starting up.", argv0); avahi_set_proc_title(argv0, "%s: starting up", argv0); if (run_server(&config) == 0) r = 0; avahi_log_info("%s "PACKAGE_VERSION" exiting.", argv0); sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" exiting.", argv0); } finish: if (config.daemonize) daemon_retval_done(); avahi_server_config_free(&config.server_config); avahi_free(config.config_file); avahi_strfreev(config.publish_dns_servers); avahi_strfreev(resolv_conf_name_servers); avahi_strfreev(resolv_conf_search_domains); if (wrote_pid_file) { #ifdef ENABLE_CHROOT avahi_chroot_helper_unlink(pid_file_proc()); #else daemon_pid_file_remove(); #endif } #ifdef ENABLE_CHROOT avahi_chroot_helper_shutdown(); #endif avahi_free(argv0); return r; }
int main(int argc, char **argv) { struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; struct bpf_prog_load_attr prog_load_attr = { .prog_type = BPF_PROG_TYPE_XDP, }; int prog_fd, qidconf_map, xsks_map; struct bpf_object *obj; char xdp_filename[256]; struct bpf_map *map; int i, ret, key = 0; pthread_t pt; parse_command_line(argc, argv); if (setrlimit(RLIMIT_MEMLOCK, &r)) { fprintf(stderr, "ERROR: setrlimit(RLIMIT_MEMLOCK) \"%s\"\n", strerror(errno)); exit(EXIT_FAILURE); } snprintf(xdp_filename, sizeof(xdp_filename), "%s_kern.o", argv[0]); prog_load_attr.file = xdp_filename; if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd)) exit(EXIT_FAILURE); if (prog_fd < 0) { fprintf(stderr, "ERROR: no program found: %s\n", strerror(prog_fd)); exit(EXIT_FAILURE); } map = bpf_object__find_map_by_name(obj, "qidconf_map"); qidconf_map = bpf_map__fd(map); if (qidconf_map < 0) { fprintf(stderr, "ERROR: no qidconf map found: %s\n", strerror(qidconf_map)); exit(EXIT_FAILURE); } map = bpf_object__find_map_by_name(obj, "xsks_map"); xsks_map = bpf_map__fd(map); if (xsks_map < 0) { fprintf(stderr, "ERROR: no xsks map found: %s\n", strerror(xsks_map)); exit(EXIT_FAILURE); } if (bpf_set_link_xdp_fd(opt_ifindex, prog_fd, opt_xdp_flags) < 0) { fprintf(stderr, "ERROR: link set xdp fd failed\n"); exit(EXIT_FAILURE); } ret = bpf_map_update_elem(qidconf_map, &key, &opt_queue, 0); if (ret) { fprintf(stderr, "ERROR: bpf_map_update_elem qidconf\n"); exit(EXIT_FAILURE); } /* Create sockets... */ xsks[num_socks++] = xsk_configure(NULL); #if RR_LB for (i = 0; i < MAX_SOCKS - 1; i++) xsks[num_socks++] = xsk_configure(xsks[0]->umem); #endif /* ...and insert them into the map. */ for (i = 0; i < num_socks; i++) { key = i; ret = bpf_map_update_elem(xsks_map, &key, &xsks[i]->sfd, 0); if (ret) { fprintf(stderr, "ERROR: bpf_map_update_elem %d\n", i); exit(EXIT_FAILURE); } } signal(SIGINT, int_exit); signal(SIGTERM, int_exit); signal(SIGABRT, int_exit); setlocale(LC_ALL, ""); ret = pthread_create(&pt, NULL, poller, NULL); lassert(ret == 0); prev_time = get_nsecs(); if (opt_bench == BENCH_RXDROP) rx_drop_all(); else if (opt_bench == BENCH_TXONLY) tx_only(xsks[0]); else l2fwd(xsks[0]); return 0; }
int main(int argc, char *argv[]) { isc_result_t result; #ifdef HAVE_LIBSCF char *instance = NULL; #endif /* * Record version in core image. * strings named.core | grep "named version:" */ strlcat(version, #if defined(NO_VERSION_DATE) || !defined(__DATE__) "named version: BIND " VERSION, #else "named version: BIND " VERSION " (" __DATE__ ")", #endif sizeof(version)); result = isc_file_progname(*argv, program_name, sizeof(program_name)); if (result != ISC_R_SUCCESS) ns_main_earlyfatal("program name too long"); if (strcmp(program_name, "lwresd") == 0) ns_g_lwresdonly = ISC_TRUE; isc_assertion_setcallback(assertion_failed); isc_error_setfatal(library_fatal_error); isc_error_setunexpected(library_unexpected_error); ns_os_init(program_name); dns_result_register(); dst_result_register(); isccc_result_register(); parse_command_line(argc, argv); /* * Warn about common configuration error. */ if (ns_g_chrootdir != NULL) { int len = strlen(ns_g_chrootdir); if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 && (ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\')) ns_main_earlywarning("config filename (-c %s) contains " "chroot path (-t %s)", ns_g_conffile, ns_g_chrootdir); } result = isc_mem_create(0, 0, &ns_g_mctx); if (result != ISC_R_SUCCESS) ns_main_earlyfatal("isc_mem_create() failed: %s", isc_result_totext(result)); isc_mem_setname(ns_g_mctx, "main", NULL); setup(); /* * Start things running and then wait for a shutdown request * or reload. */ do { result = isc_app_run(); if (result == ISC_R_RELOAD) { ns_server_reloadwanted(ns_g_server); } else if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_app_run(): %s", isc_result_totext(result)); /* * Force exit. */ result = ISC_R_SUCCESS; } } while (result != ISC_R_SUCCESS); #ifdef HAVE_LIBSCF if (ns_smf_want_disable == 1) { result = ns_smf_get_instance(&instance, 1, ns_g_mctx); if (result == ISC_R_SUCCESS && instance != NULL) { if (smf_disable_instance(instance, 0) != 0) UNEXPECTED_ERROR(__FILE__, __LINE__, "smf_disable_instance() " "failed for %s : %s", instance, scf_strerror(scf_error())); } if (instance != NULL) isc_mem_free(ns_g_mctx, instance); } #endif /* HAVE_LIBSCF */ cleanup(); if (want_stats) { isc_mem_stats(ns_g_mctx, stdout); isc_mutex_stats(stdout); } if (ns_g_memstatistics && memstats != NULL) { FILE *fp = NULL; result = isc_stdio_open(memstats, "w", &fp); if (result == ISC_R_SUCCESS) { isc_mem_stats(ns_g_mctx, fp); isc_mutex_stats(fp); isc_stdio_close(fp); } } isc_mem_destroy(&ns_g_mctx); isc_mem_checkdestroyed(stderr); ns_main_setmemstats(NULL); isc_app_finish(); ns_os_closedevnull(); ns_os_shutdown(); return (0); }
/* run a check */ int run_check(char *processed_command, char **ret, char **err) { char *argv[MAX_CMD_ARGS]; FILE *fp; pid_t pid; int pipe_stdout[2], pipe_stderr[2], pipe_rwe[3]; int retval; sigset_t mask; #ifdef EMBEDDEDPERL retval = run_epn_check(processed_command, ret, err); if(retval != GM_NO_EPN) { return retval; } #endif /* check for check execution method (shell or execvp) * command line does not have to contain shell meta characters * and cmd must begin with a /. Otherwise "BLAH=BLUB cmd" would lead * to file not found errors */ if((*processed_command == '/' || *processed_command == '.') && !strpbrk(processed_command,"!$^&*()~[]\\|{};<>?`\"'")) { /* use the fast execvp when there are no shell characters */ gm_log( GM_LOG_TRACE, "using execvp, no shell characters found\n" ); parse_command_line(processed_command,argv); if(!argv[0]) _exit(STATE_UNKNOWN); if(pipe(pipe_stdout)) { gm_log( GM_LOG_ERROR, "error creating pipe: %s\n", strerror(errno)); _exit(STATE_UNKNOWN); } if(pipe(pipe_stderr)) { gm_log( GM_LOG_ERROR, "error creating pipe: %s\n", strerror(errno)); _exit(STATE_UNKNOWN); } if((pid=fork())<0){ gm_log( GM_LOG_ERROR, "fork error\n"); _exit(STATE_UNKNOWN); } else if(!pid){ /* remove all customn signal handler */ sigfillset(&mask); sigprocmask(SIG_UNBLOCK, &mask, NULL); /* child process */ if((dup2(pipe_stdout[1],STDOUT_FILENO)<0)){ gm_log( GM_LOG_ERROR, "dup2 error\n"); _exit(STATE_UNKNOWN); } if((dup2(pipe_stderr[1],STDERR_FILENO)<0)){ gm_log( GM_LOG_ERROR, "dup2 error\n"); _exit(STATE_UNKNOWN); } close(pipe_stdout[1]); close(pipe_stderr[1]); current_child_pid = getpid(); execvp(argv[0], argv); if(errno == 2) _exit(127); if(errno == 13) _exit(126); _exit(STATE_UNKNOWN); } /* parent */ /* prepare stdout pipe reading */ close(pipe_stdout[1]); fp=fdopen(pipe_stdout[0],"r"); if(!fp){ gm_log( GM_LOG_ERROR, "fdopen error\n"); _exit(STATE_UNKNOWN); } *ret = extract_check_result(fp, GM_DISABLED); fclose(fp); /* prepare stderr pipe reading */ close(pipe_stderr[1]); fp=fdopen(pipe_stderr[0],"r"); if(!fp){ gm_log( GM_LOG_ERROR, "fdopen error\n"); _exit(STATE_UNKNOWN); } *err = extract_check_result(fp, GM_ENABLED); fclose(fp); close(pipe_stdout[0]); close(pipe_stderr[0]); if(waitpid(pid,&retval,0)!=pid) retval=-1; } else { /* use the slower popen when there were shell characters */ gm_log( GM_LOG_TRACE, "using popen, found shell characters\n" ); current_child_pid = getpid(); pid = popenRWE(pipe_rwe, processed_command); /* extract check result */ fp=fdopen(pipe_rwe[1],"r"); if(!fp){ gm_log( GM_LOG_ERROR, "fdopen error\n"); _exit(STATE_UNKNOWN); } *ret = extract_check_result(fp, GM_DISABLED); fclose(fp); /* extract check stderr */ fp=fdopen(pipe_rwe[2],"r"); if(!fp){ gm_log( GM_LOG_ERROR, "fdopen error\n"); _exit(STATE_UNKNOWN); } *err = extract_check_result(fp, GM_ENABLED); fclose(fp); /* close the process */ retval=pcloseRWE(pid, pipe_rwe); } return retval; }
int main(int argc, char *argv[]) { int ret = 0,inputs,i,j,outputs; ADMXRC2_STATUS status; ADMXRC2_HANDLE card = ADMXRC2_HANDLE_INVALID_VALUE; ADMXRC2_CARD_INFO cardInfo; ADMXRC2_SPACE_INFO spInfo; volatile uint32_t* fpgaSpace; unsigned long dataOut[30],dataIn[30]; const char* filename; Option options[3]; Arguments arguments; int use64bit; /* Set up expected options */ options[0].key = "card"; options[0].type = Option_uint; options[0].def.uintVal = 0; options[0].meaning = "ID of card to use"; options[1].key = "index"; options[1].type = Option_uint; options[1].def.uintVal = 0; options[1].meaning = "index of card to use"; options[2].key = "64"; options[2].type = Option_boolean; options[2].def.booleanVal = FALSE; options[2].meaning = "TRUE => use 64 bit local bus"; arguments.nOption = 3; arguments.option = options; arguments.nParamType = 0; arguments.minNParam = 0; /* Parse command line */ parse_command_line("simple", argc, argv, &arguments); if (!options[1].specified) { ADMXRC2_CARDID cardID = options[0].value.uintVal; status = ADMXRC2_OpenCard(cardID, &card); if (status != ADMXRC2_SUCCESS) { printf("Failed to open card with ID %ld: %s\n", (unsigned long) cardID, ADMXRC2_GetStatusString(status)); ret = -1; goto done; } } else { unsigned int index = options[1].value.uintVal; status = ADMXRC2_OpenCardByIndex(index, &card); if (status != ADMXRC2_SUCCESS) { printf("Failed to open card with index %ld: %s\n", (unsigned long) index, ADMXRC2_GetStatusString(status)); ret = -1; goto done; } } use64bit = options[2].value.booleanVal; /* Get the address of FPGA space */ status = ADMXRC2_GetSpaceInfo(card, 0, &spInfo); if (status != ADMXRC2_SUCCESS) { printf("Failed to get space 0 info: %s\n", ADMXRC2_GetStatusString(status)); ret = -1; goto done; } fpgaSpace = (volatile uint32_t*) spInfo.VirtualBase; /* Set local bus clock to nominal frequency */ status = ADMXRC2_SetClockRate(card, ADMXRC2_CLOCK_LCLK, 33.0e6, NULL); if (status != ADMXRC2_SUCCESS) { printf("Failed to set LCLK to %.1fMHz: %s\n", 33.0e6, ADMXRC2_GetStatusString(status)); ret = -1; goto done; } printf("====================\n" ); printf("Enter values for I/O\n" ); printf("====================\n" ); for(i=0;i<1;i++) { scanf("%lx", &dataOut[i]); fpgaSpace[i] = os_cpu_to_le32((uint32_t) dataOut[i]); } for(i=0;i<2;i++) {dataIn[i] = (unsigned long) os_le32_to_cpu(fpgaSpace[i]); for(j=0;j<5;j++); } for(i=0;i<1;i++) {printf("Input = %8.8lx\n",(unsigned long) dataOut[i]);} //for(i=0;i<2;i++) //{ printf("output = %8.8lx\n",(unsigned long) dataIn[0]); printf("state = %8.8lx\n",(unsigned long) dataIn[1]); //} done: if (card != ADMXRC2_HANDLE_INVALID_VALUE) { ADMXRC2_CloseCard(card); } return ret; }
int main (int argc, const char *argv[]) { int fd; unsigned int size; char *filename; long res; char *buf; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); /* Initialize h5tools lib */ h5tools_init(); parse_command_line (argc, argv); if (nbytes == NULL) { /* missing arg */ error_msg("missing size\n"); usage (h5tools_getprogname()); exit (EXIT_FAILURE); } if (argc <= (opt_ind)) { error_msg("missing file name\n"); usage (h5tools_getprogname()); exit (EXIT_FAILURE); } filename = HDstrdup (argv[opt_ind]); size = 0; res = sscanf (nbytes, "%u", &size); if (res == EOF) { /* fail */ error_msg("missing file name\n"); usage (h5tools_getprogname()); exit (EXIT_FAILURE); } fd = HDopen (filename, O_RDONLY, 0); if (fd < 0) { error_msg("can't open file %s\n", filename); exit (EXIT_FAILURE); } buf = (char *)HDmalloc ((unsigned)(size + 1)); if (buf == NULL) { HDclose (fd); exit (EXIT_FAILURE); } res = HDread (fd, buf, (unsigned)size); if (res < (long)size) { if (buf) free (buf); HDclose (fd); exit (EXIT_FAILURE); } HDwrite (1, buf, (unsigned)size); if (buf) free (buf); HDclose (fd); return (EXIT_SUCCESS); }
int main (int argc, char* argv[]) { char filename1[200]; char filename2[200]; char pairs_file[200]; char fileout[200]; FILE* query_fp = 0; FILE* reference_fp = 0; FILE* fp_pairs = 0; FILE* fpout = stdout; int total_pairs = 0; pair_struct* pairs = 0; /* Set Default Parameter Values*/ length_5p_for_weighting = 8; /* The 5' sequence length to be weighed except for the last residue*/ scale = 4.0; /* The 5' miRNA scaling parameter*/ strict = 0; /* Strict seed model on/off*/ debug = 0; /* Debugging mode on/off*/ key_value_pairs = 0; gap_open = -9.0; /* Gap-open Penalty*/ gap_extend = -4.0; /* Gap-extend Penalty*/ score_threshold = 140.0; /* SW Score Threshold for reporting hits*/ energy_threshold = 1.0; /* Energy Threshold (DG) for reporting hits*/ verbosity = 1; /* Verbose mode on/off*/ outfile = 0; /* Dump to file on/off*/ truncated = 0; /* Truncate sequences on/off*/ no_energy = 0; /* Turn off Vienna Energy Calcs - FASTER*/ restricted = 0; /* Perform restricted search space*/ parse_command_line(argc, argv, filename1, filename2, fileout, pairs_file); if (gap_open > 0.0 || gap_extend > 0.0) { fprintf(stderr, "Error: gap penalties may not be greater than 0\n"); return 1; } if (truncated < 0) { fprintf(stderr, "Error: negative value give for UTR truncation\n"); return 1; } if ((query_fp = fopen(filename1, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename1); return 1; } if ((reference_fp = fopen(filename2, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", filename2); return 1; } fclose(reference_fp); if ((outfile) && ((fpout = fopen(fileout, "w")) == NULL)) { fprintf(stderr, "Error: Cannot create output file %s\n", fileout); return 1; } if (restricted) { if ((fp_pairs = fopen(pairs_file, "r")) == NULL) { fprintf(stderr, "Error: Cannot open restrict pairs file %s\n", pairs_file); return 1; } /* Initialize the pairs list for restriced searches*/ total_pairs = load_pairs(fp_pairs, &pairs); fclose(fp_pairs); } initialize_globals(); print_parameters(filename1, filename2, fpout); if (restricted && verbosity) { printf("Performing Restricted Scan on:%d pairs\n", total_pairs); } find_targets(query_fp, fpout, pairs, total_pairs, filename2); destroy_globals(); if (outfile) fclose(fpout); fclose(query_fp); return 0; }
int main(int argc, char *argv[]) { if(setpgrp() < 0) perror("setpgrp()"); if (parse_command_line(argc, argv) != 0) return 1; #ifdef WIN32 // if under windows, we need to define the locale directory bindtextdomain("poker2d", "./../locale"); #endif bind_textdomain_codeset("poker2d","UTF-8"); textdomain("poker2d"); if (g_display) { char tmp[64]; snprintf(tmp, sizeof (tmp), "DISPLAY=%s", g_display); putenv(tmp); } if (g_gtk_rc_file) { char* file_name = strrchr(g_gtk_rc_file, '/')+1; int path_len = strlen(g_gtk_rc_file); int name_len = strlen(file_name); int newname_len = strlen(gettext(file_name)); char* new_gtk_rc = malloc(sizeof(char)*(path_len-name_len+newname_len)); memset(new_gtk_rc, 0, path_len-name_len+newname_len); memcpy(new_gtk_rc, g_gtk_rc_file, path_len-name_len); strcat(new_gtk_rc, gettext(file_name)); char* tmp[2] = { new_gtk_rc, 0}; gtk_rc_set_default_files(tmp); g_message("%s\n", new_gtk_rc); g_message(gettext("CANCEL")); g_free(g_gtk_rc_file); g_free(new_gtk_rc); } gtk_init (&argc, &argv); set_verbose(g_want_verbose); if (!init_interface_io(g_hostname ? g_hostname : "127.0.0.1")) return 1; if (g_smiley_path) create_smiley_array(g_smiley_path, "smileys.xml"); else create_smiley_array(".", "smileys.xml"); gtk_main (); destroy_smiley_array(); if (g_smiley_path) g_free(g_smiley_path); if (g_data_dir) g_free(g_data_dir); if (g_display) g_free(g_display); gui_set_glade_file(NULL); exit(0); }
int main( int argc, char *argv[] ) { int ret; int fd; struct stat stat; void *ptr = MAP_FAILED; Entity::vector faces; DGIFFHeader header = { magic: { 'D', 'G', 'I', 'F', 'F' }, major: 0, minor: 0, flags: DGIFF_FLAG_LITTLE_ENDIAN, num_faces: 0 }; direct_initialize(); direct_debug_config_domain( "mkdgiff", true ); direct_config->debug = true; direct_config->debugmem = true; /* Parse the command line. */ if (!parse_command_line( argc, argv )) return -1; /* Open the file. */ fd = open( filename, O_RDONLY ); if (fd < 0) { ret = errno2result( errno ); D_PERROR( "Font/DGIFF: Failure during open() of '%s'!\n", filename ); return ret; } /* Query file size etc. */ if (fstat( fd, &stat ) < 0) { ret = errno2result( errno ); D_PERROR( "Font/DGIFF: Failure during fstat() of '%s'!\n", filename ); goto out; } /* Memory map the file. */ ptr = mmap( NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); if (ptr == MAP_FAILED) { ret = errno2result( errno ); D_PERROR( "Font/DGIFF: Failure during mmap() of '%s'!\n", filename ); goto out; } get_entities( (const char*) ptr, stat.st_size, faces ); header.num_faces = faces.size(); fwrite( &header, sizeof(header), 1, stdout ); for (Entity::vector::const_iterator iter = faces.begin(); iter != faces.end(); iter++) { const Face *face = dynamic_cast<const Face*>( *iter ); face->Dump(); ret = do_face( face ); if (ret) goto out; } out: if (ptr != MAP_FAILED) munmap( ptr, stat.st_size ); close( fd ); direct_print_memleaks(); direct_shutdown(); return ret; }
static int rtsp_listen(AVFormatContext *s) { RTSPState *rt = s->priv_data; char proto[128], host[128], path[512], auth[128]; char uri[500]; int port; int default_port = RTSP_DEFAULT_PORT; char tcpname[500]; const char *lower_proto = "tcp"; unsigned char rbuf[4096]; unsigned char method[10]; int rbuflen = 0; int ret; enum RTSPMethod methodcode; /* extract hostname and port */ av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host), &port, path, sizeof(path), s->filename); /* ff_url_join. No authorization by now (NULL) */ ff_url_join(rt->control_uri, sizeof(rt->control_uri), proto, NULL, host, port, "%s", path); if (!strcmp(proto, "rtsps")) { lower_proto = "tls"; default_port = RTSPS_DEFAULT_PORT; } if (port < 0) port = default_port; /* Create TCP connection */ ff_url_join(tcpname, sizeof(tcpname), lower_proto, NULL, host, port, "?listen&listen_timeout=%d", rt->initial_timeout * 1000); if (ret = ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE, &s->interrupt_callback, NULL)) { av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n"); return ret; } rt->state = RTSP_STATE_IDLE; rt->rtsp_hd_out = rt->rtsp_hd; for (;;) { /* Wait for incoming RTSP messages */ ret = read_line(s, rbuf, sizeof(rbuf), &rbuflen); if (ret < 0) return ret; ret = parse_command_line(s, rbuf, rbuflen, uri, sizeof(uri), method, sizeof(method), &methodcode); if (ret) { av_log(s, AV_LOG_ERROR, "RTSP: Unexpected Command\n"); return ret; } if (methodcode == ANNOUNCE) { ret = rtsp_read_announce(s); rt->state = RTSP_STATE_PAUSED; } else if (methodcode == OPTIONS) { ret = rtsp_read_options(s); } else if (methodcode == RECORD) { ret = rtsp_read_record(s); if (!ret) return 0; // We are ready for streaming } else if (methodcode == SETUP) ret = rtsp_read_setup(s, host, uri); if (ret) { ffurl_close(rt->rtsp_hd); return AVERROR_INVALIDDATA; } } return 0; }
int main(int argc, char* argv[]) { setup_corefile(); /* we wan't core files for debug */ setup_signals(); srandom(time(NULL)); /* random seed */ /* check if we are just doing a configuration change */ if((argc > 1) && (strcasecmp(argv[1], "conf")==0)) return cmd_conf(argc-2, &argv[2]); parse_command_line(argc, argv); /* parse command line options */ printf("Starting %s, CopyRight PTlink IRC Software 1999-2005\n", svs_version); printf("Setting ircsvs log file to "LOGPATH "/ircsvs.log\n"); /* rotate the logsize if required */ check_logsize(); if(init_log(LOGPATH "/ircsvs.log") == 0) { fprintf(stderr,"ERROR: Could not create log file\n"); return 3; } slog(L_INFO, "Starting %s", svs_version); #if 0 if(TimeZone) { #ifdef HAVE_SETENV setenv("TZ",TimeZone,1); tzset(); #else fprintf(stderr, "TimeZone defined but setenv() is not supported on this OS!"); #endif } #endif /* Let's init the irc functions first, we may use them on modules */ e_expire = mod_register_event("e_expire"); e_complete = mod_register_event("e_complete"); if(load_modules_file("ircsvs") < 0) { fprintf(stderr,"ERROR: Error loading modules\n"); return -3; } stdlog(L_INFO, "All modules succesfully loaded"); /* check it here to avoid "Server already exists" uppon connection */ if( nofork == 0 ) check_pidfile(); #if 0 #warning need to move ExpireInterval to the module if(ExpireInterval) { stdlog(L_INFO, "Running expire routines..."); ev_expire(NULL, NULL); stdlog(L_INFO,"Expire interval set to %d minute(s)", ExpireInterval / 60); irc_AddEvent(ET_LOOP, ev_expire); /* set the expire routines */ } else stdlog(L_WARN, "Data expiration is disabled"); #endif stdlog(L_INFO, "Services startup completed."); mod_do_event(e_complete, NULL, NULL); return 0; }
int main (int argc, char **argv) { FILE *f; parse_command_line(argc, argv); /* Log to the console if not daemonizing. */ openlog("sleepd", LOG_PID | (daemonize ? 0 : LOG_PERROR), LOG_DAEMON); /* Set up a signal handler for SIGTERM to clean up things. */ signal(SIGTERM, cleanup); /* And a handler for SIGHUP, to reaload control file. */ signal(SIGHUP, loadcontrol); loadcontrol(0); if (! use_events) { if (! have_irqs && ! autoprobe) { fprintf(stderr, "No irqs specified.\n"); exit(1); } } if (daemonize) { if (daemon(0,0) == -1) { perror("daemon"); exit(1); } if ((f=fopen(PID_FILE, "w")) == NULL) { syslog(LOG_ERR, "unable to write %s", PID_FILE); exit(1); } else { fprintf(f, "%i\n", getpid()); fclose(f); } } if (apm_exists() != 0) { if (! sleep_command) sleep_command=acpi_sleep_command; /* Chosing between hal and acpi backends is tricky, * because acpi may report no batteries due to the battery * being absent (but inserted later), or due to battery * info no longer being available by acpi in new kernels. * Meanwhile, hal may fail if hald is not yet * running, but might work later. * * The strategy used is to check if acpi reports an AC * adapter, or a battery. If it reports neither, we assume * that the kernel no longer supports acpi power info, and * use hal. */ if (acpi_supported() && (acpi_ac_count > 0 || acpi_batt_count > 0)) { use_acpi=1; } #ifdef HAL else if (simplehal_supported()) { use_simplehal=1; } else { syslog(LOG_NOTICE, "failed to connect to hal on startup, but will try to use it anyway"); use_simplehal=1; } #else else { fprintf(stderr, "sleepd: no APM or ACPI support detected\n"); exit(1); } #endif }
int main(int argc, char **argv) { int i,j; int initial,fixup,spec2k6,legend; int num_benchmarks; char temp_input[BUFSIZ]; parse_command_line(argc,argv, &num_runs,&initial, &legend,&spec2k6,&num_benchmarks); if (initial) fixup=FIXUP_NONE; else fixup=FIXUP_ALL; machines=spec2k_machines; printf("\\begin{table*}[tbp]\n"); printf("\\begin{sf}\n"); printf("\\begin{scriptsize}\n"); printf("\\begin{center}\n"); printf("\\begin{tabular}{|l||r||r|r|r||"); for(i=0;i<REAL_MACHINES;i++) { if (!(!machines[i].is_spec2k6&&spec2k6)) { printf("r|"); } } printf("}\n"); printf("\\hline\n"); printf("Benchmark & "); printf("\\parbox[b]{1.2cm}{\\flushright Overall\\\\Standard\\\\Deviation\\\\(mean)} & "); printf("\\begin{sideways}\\parbox{2cm}{Pin}\\end{sideways} &"); printf("\\begin{sideways}\\parbox{2cm}{Qemu}\\end{sideways} &"); printf("\\begin{sideways}\\parbox{2cm}{Valgrind}\\end{sideways} "); for(i=0;i<REAL_MACHINES;i++) { if (!(!machines[i].is_spec2k6&&spec2k6)) { printf("& "); printf("\\begin{sideways}\\parbox{2cm}{"); printf("%s",machines[i].processor2); printf("\\\\%s",machines[i].processor1); printf("}\\end{sideways} "); } } printf("\\\\\n"); printf("\\hline\n"); our_stats=calloc(sizeof(struct stats),num_benchmarks); for(j=0;j<num_benchmarks;j++) { load_stats(num_runs,spec2k6,our_stats,argv[(j*2)+BENCH_START], argv[(j*2)+BENCH_START+1],argv[TREE_ARG],j,fixup); } for(j=0;j<num_benchmarks;j++) { if (!strcmp("makerand",argv[(j*2)+BENCH_START+1])) { strcpy(temp_input,"mkrnd"); } else if (!strcmp("default",argv[(j*2)+BENCH_START+1])) { strcpy(temp_input," "); } else if (!strcmp("foreman_baseline",argv[(j*2)+BENCH_START+1])) { strcpy(temp_input,"forebase"); } else if (!strcmp("foreman_main",argv[(j*2)+BENCH_START+1])) { strcpy(temp_input,"foremain"); } else if (!strcmp("sss_main",argv[(j*2)+BENCH_START+1])) { strcpy(temp_input,"sss"); } else { strcpy(temp_input,argv[(j*2)+BENCH_START+1]); } printf("%s %s &",argv[(j*2)+BENCH_START],temp_input); /* mean */ print_diff((long long)(our_stats[j].bench_stdev),LO,MID,HI); //print_commas( (long long)(our_stats[j].bench_stdev)); printf(" & "); /* PIN */ if (!our_stats[j].machine_mean_valid[PIN]) { print_blank(); } else { print_diff((long long)(our_stats[j].machine_stdev[PIN]),LO,MID,HI); print_num_points(our_stats[j].num_points[PIN]); } printf(" & "); /* QEMU */ if (!our_stats[j].machine_mean_valid[QEMU]) { print_blank(); } else { print_diff((long long)(our_stats[j].machine_stdev[QEMU]),LO,MID,HI); print_num_points(our_stats[j].num_points[QEMU]); } printf(" & "); if (!our_stats[j].machine_mean_valid[VALGRIND]) { print_blank(); } else { print_diff((long long)(our_stats[j].machine_stdev[VALGRIND]),LO,MID,HI); print_num_points(our_stats[j].num_points[VALGRIND]); } for(i=0;i<REAL_MACHINES;i++) { if (!(!machines[i].is_spec2k6&&spec2k6)) { printf(" & "); if (!our_stats[j].machine_mean_valid[i]) { print_blank(); } else { print_diff((long long)(our_stats[j].machine_stdev[i]),LO,MID,HI); print_num_points(our_stats[j].num_points[i]); } } } printf("\\\\\n"); if (j%5==4) printf("\\hline\n"); } printf("\\hline\n"); printf("\\end{tabular}\n"); printf("\\end{center}\n"); return 0; }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { SOCKET sockfd; SOCKADDR_IN my_addr; SOCKADDR_IN your_addr; HANDLE thread; int i, sin_size, ret; parse_command_line(lpCmdLine); if (init_server() != 0) return 1; sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd == -1) { WSACleanup(); return 1; } my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = INADDR_ANY; my_addr.sin_port = htons(ftp_control_port); memset(my_addr.sin_zero, 0, sizeof(my_addr.sin_zero)); if (bind(sockfd, (SOCKADDR *) &my_addr, sizeof(my_addr)) == -1 || listen(sockfd, MAX_SESSION) == -1) { closesocket(sockfd); WSACleanup(); return 1; } for (;;) { do { fd_set readfds; TIMEVAL t; i = get_session_slot(); FD_ZERO(&readfds); FD_SET(sockfd, &readfds); t.tv_sec = 1; t.tv_usec = 0; ret = select(0, &readfds, NULL, NULL, &t); } while (!terminated && ret == 0); if (terminated) break; sin_size = sizeof(your_addr); session[i].control = accept(sockfd, (SOCKADDR *) &your_addr, &sin_size); session[i].host = ntohl(your_addr.sin_addr.s_addr); session[i].sid = i; thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) manage_ftp_session, (void *) &session[i], 0, (DWORD *) &session[i].running); SetThreadPriority(thread, THREAD_PRIORITY_LOWEST); } closesocket(sockfd); WSACleanup(); return 0; }
int main(int argc, char *argv[]) { /* * Purpose * ======= * * The driver program SLINSOLX1. * * This example illustrates how to use SGSSVX to solve systems with the same * A but different right-hand side. * In this case, we factorize A only once in the first call to DGSSVX, * and reuse the following data structures in the subsequent call to SGSSVX: * perm_c, perm_r, R, C, L, U. * */ char equed[1]; yes_no_t equil; trans_t trans; SuperMatrix A, L, U; SuperMatrix B, X; NCformat *Astore; NCformat *Ustore; SCformat *Lstore; float *a; int *asub, *xa; int *perm_c; /* column permutation vector */ int *perm_r; /* row permutations from partial pivoting */ int *etree; void *work; int info, lwork, nrhs, ldx; int i, m, n, nnz; float *rhsb, *rhsx, *xact; float *R, *C; float *ferr, *berr; float u, rpg, rcond; mem_usage_t mem_usage; superlu_options_t options; SuperLUStat_t stat; extern void parse_command_line(); #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); #endif /* Defaults */ lwork = 0; nrhs = 1; equil = YES; u = 1.0; trans = NOTRANS; /* Set the default values for options argument: options.Fact = DOFACT; options.Equil = YES; options.ColPerm = COLAMD; options.DiagPivotThresh = 1.0; options.Trans = NOTRANS; options.IterRefine = NOREFINE; options.SymmetricMode = NO; options.PivotGrowth = NO; options.ConditionNumber = NO; options.PrintStat = YES; */ set_default_options(&options); /* Can use command line input to modify the defaults. */ parse_command_line(argc, argv, &lwork, &u, &equil, &trans); options.Equil = equil; options.DiagPivotThresh = u; options.Trans = trans; if ( lwork > 0 ) { work = SUPERLU_MALLOC(lwork); if ( !work ) { ABORT("SLINSOLX: cannot allocate work[]"); } } /* Read matrix A from a file in Harwell-Boeing format.*/ sreadhb(&m, &n, &nnz, &a, &asub, &xa); sCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_S, SLU_GE); Astore = A.Store; printf("Dimension %dx%d; # nonzeros %d\n", A.nrow, A.ncol, Astore->nnz); if ( !(rhsb = floatMalloc(m * nrhs)) ) ABORT("Malloc fails for rhsb[]."); if ( !(rhsx = floatMalloc(m * nrhs)) ) ABORT("Malloc fails for rhsx[]."); sCreate_Dense_Matrix(&B, m, nrhs, rhsb, m, SLU_DN, SLU_S, SLU_GE); sCreate_Dense_Matrix(&X, m, nrhs, rhsx, m, SLU_DN, SLU_S, SLU_GE); xact = floatMalloc(n * nrhs); ldx = n; sGenXtrue(n, nrhs, xact, ldx); sFillRHS(trans, nrhs, xact, ldx, &A, &B); if ( !(etree = intMalloc(n)) ) ABORT("Malloc fails for etree[]."); if ( !(perm_r = intMalloc(m)) ) ABORT("Malloc fails for perm_r[]."); if ( !(perm_c = intMalloc(n)) ) ABORT("Malloc fails for perm_c[]."); if ( !(R = (float *) SUPERLU_MALLOC(A.nrow * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for R[]."); if ( !(C = (float *) SUPERLU_MALLOC(A.ncol * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for C[]."); if ( !(ferr = (float *) SUPERLU_MALLOC(nrhs * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for ferr[]."); if ( !(berr = (float *) SUPERLU_MALLOC(nrhs * sizeof(float))) ) ABORT("SUPERLU_MALLOC fails for berr[]."); /* Initialize the statistics variables. */ StatInit(&stat); /* ONLY PERFORM THE LU DECOMPOSITION */ B.ncol = 0; /* Indicate not to solve the system */ sgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); printf("LU factorization: sgssvx() returns info %d\n", info); if ( info == 0 || info == n+1 ) { if ( options.PivotGrowth ) printf("Recip. pivot growth = %e\n", rpg); if ( options.ConditionNumber ) printf("Recip. condition number = %e\n", rcond); Lstore = (SCformat *) L.Store; Ustore = (NCformat *) U.Store; printf("No of nonzeros in factor L = %d\n", Lstore->nnz); printf("No of nonzeros in factor U = %d\n", Ustore->nnz); printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n); printf("FILL ratio = %.1f\n", (float)(Lstore->nnz + Ustore->nnz - n)/nnz); printf("L\\U MB %.3f\ttotal MB needed %.3f\n", mem_usage.for_lu/1e6, mem_usage.total_needed/1e6); fflush(stdout); } else if ( info > 0 && lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); } if ( options.PrintStat ) StatPrint(&stat); StatFree(&stat); /* ------------------------------------------------------------ NOW WE SOLVE THE LINEAR SYSTEM USING THE FACTORED FORM OF A. ------------------------------------------------------------*/ options.Fact = FACTORED; /* Indicate the factored form of A is supplied. */ B.ncol = nrhs; /* Set the number of right-hand side */ /* Initialize the statistics variables. */ StatInit(&stat); sgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); printf("Triangular solve: sgssvx() returns info %d\n", info); if ( info == 0 || info == n+1 ) { /* This is how you could access the solution matrix. */ float *sol = (float*) ((DNformat*) X.Store)->nzval; if ( options.IterRefine ) { printf("Iterative Refinement:\n"); printf("%8s%8s%16s%16s\n", "rhs", "Steps", "FERR", "BERR"); for (i = 0; i < nrhs; ++i) printf("%8d%8d%16e%16e\n", i+1, stat.RefineSteps, ferr[i], berr[i]); } fflush(stdout); } else if ( info > 0 && lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); } if ( options.PrintStat ) StatPrint(&stat); StatFree(&stat); SUPERLU_FREE (rhsb); SUPERLU_FREE (rhsx); SUPERLU_FREE (xact); SUPERLU_FREE (etree); SUPERLU_FREE (perm_r); SUPERLU_FREE (perm_c); SUPERLU_FREE (R); SUPERLU_FREE (C); SUPERLU_FREE (ferr); SUPERLU_FREE (berr); Destroy_CompCol_Matrix(&A); Destroy_SuperMatrix_Store(&B); Destroy_SuperMatrix_Store(&X); if ( lwork == 0 ) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } else if ( lwork > 0 ) { SUPERLU_FREE(work); } #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Exit main()"); #endif }
int main(int argc, char * const argv[]) { u8 *buf; int found = 0; unsigned int fp; if (sizeof(u8) != 1) { fprintf(stderr, "%s: compiler incompatibility\n", argv[0]); exit(255); } /* Set default option values */ opt.devmem = DEFAULT_MEM_DEV; opt.flags = 0; if (parse_command_line(argc, argv)<0) exit(2); if (opt.flags & FLAG_HELP) { print_help(); return 0; } if (opt.flags & FLAG_VERSION) { printf("%s\n", VERSION); return 0; } if (!(opt.flags & FLAG_QUIET)) printf("# vpddecode %s\n", VERSION); if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL) exit(1); for (fp = 0; fp <= 0xFFF0; fp += 4) { u8 *p = buf + fp; if (memcmp((char *)p, "\252\125VPD", 5) == 0 && fp + p[5] - 1 <= 0xFFFF) { if (fp % 16 && !(opt.flags & FLAG_QUIET)) printf("# Unaligned address (%#x)\n", 0xf0000 + fp); if (opt.flags & FLAG_DUMP) { dump(p, p[5]); found++; } else { if (decode(p)) found++; } } } free(buf); if (!found && !(opt.flags & FLAG_QUIET)) printf("# No VPD structure found, sorry.\n"); return 0; }
/* If mark_char is not '\0', we bold names ending with it. */ int request_strings(const char * const * const _entries, const int _num_entries, int n, const int _max_name_len, int _mark_char) { action a; input_class ic; int c, i, ne_lines0, ne_columns0; assert(_num_entries > 0); ne_lines0 = ne_columns0 = max_names_per_line = max_names_per_col = x = y = page = 0; entries = _entries; num_entries = _num_entries; max_name_len = _max_name_len + 1; mark_char = _mark_char; while(TRUE) { if (ne_lines0 != ne_lines || ne_columns0 != ne_columns) { if (ne_lines0 && ne_columns0 ) n = PXY2N(page,x,y); if (!(max_names_per_line = ne_columns / (max_name_len))) max_names_per_line = 1; max_names_per_col = ne_lines - 1; names_per_page = max_names_per_line * max_names_per_col; ne_lines0 = ne_lines; ne_columns0 = ne_columns; page = N2P(n); x = N2X(n); y = N2Y(n); print_strings(); print_message(NULL); } move_cursor(y, x * max_name_len); do c = get_key_code(); while((ic = CHAR_CLASS(c)) == IGNORE || ic == INVALID); n = PXY2N(page,x,y); switch(ic) { case ALPHA: if (n >= num_entries) n = num_entries - 1; c = localised_up_case[(unsigned char)c]; for(i = 1; i < num_entries; i++) if (localised_up_case[(unsigned char)entries[(n + i) % num_entries][0]] == c) { normalize((n + i) % num_entries); break; } break; case TAB: if (n >= num_entries) return ERROR; else return -n - 2; case RETURN: if (n >= num_entries) return ERROR; else return n; case COMMAND: if (c < 0) c = -c - 1; if ((a = parse_command_line(key_binding[c], NULL, NULL, FALSE))>=0) { switch(a) { case MOVERIGHT_A: request_move_right(); break; case MOVELEFT_A: request_move_left(); break; case MOVESOL_A: request_move_to_sol(); break; case MOVEEOL_A: request_move_to_eol(); break; case TOGGLESEOL_A: if (x != 0) x = 0; else request_move_to_eol(); break; case LINEUP_A: request_move_up(); break; case LINEDOWN_A: request_move_down(); break; case MOVEINCUP_A: request_move_inc_up(); break; case MOVEINCDOWN_A: request_move_inc_down(); break; case PAGEUP_A: case PREVPAGE_A: request_prev_page(); break; case PAGEDOWN_A: case NEXTPAGE_A: request_next_page(); break; case MOVESOF_A: request_move_to_sof(); break; case MOVEEOF_A: request_move_to_eof(); break; case TOGGLESEOF_A: request_toggle_seof(); break; case ESCAPE_A: return -1; } } break; default: break; } } }
//void copy_parameter(param_temp,¶m) //{ // param_t //} // Interface function of matlab // now assume prhs[0]: label prhs[1]: features int main(int argc, char **argv) { const char *error_msg; // fix random seed to have same results for each run // (for cross validation) srand(1); char input_file_name[1024]; char model_file_name[1024]; char param_file_name[1024]; int n_flag = 0; parse_command_line(argc, argv, input_file_name, model_file_name,n_flag,param_file_name); char char_para; int length_param = 0; double *para_entry; // //n_flag = 1; //int para_B[20] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 12,14,16, 18, 20, 25, 30,35,40,45,50}; int para_B[40] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 25, 26, 30,32, 35, 38, 40, 42, 45, 48, 50, 55, 60, 65,70,75,80, 85, 90, 95, 100, 105, 110, 115, 120}; //int para_B[32] = { 20, 24, 25, 26, 30,32, 35, 38, 40, 42, 45, 48, 50, 55, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280}; if (n_flag==1) { read_parameter(param_file_name, para_entry, char_para, length_param); } read_problem(input_file_name); error_msg = check_parameter(&prob,¶m); //parameter *param_temp = new parameter[1]; //copy_parameter(param_temp,¶m); if(error_msg) { fprintf(stderr,"Error: %s\n",error_msg); exit(1); } if(cross_validation_flag) { do_cross_validation(); } else { if(n_flag==0) { model_ = FGM_train(&prob, ¶m); printf("training is done!\n"); save_model_poly(model_file_name, model_); printf("model is saved!\n"); destroy_model(model_); } else { int i; if (char_para=='C') { length_param = length_param; }else { length_param = 40; } for (i=0;i<length_param;i++) { char param_char[1000]; char model_file[1024]; strcpy(model_file,model_file_name); if (char_para=='C') { param.C = para_entry[i]; sprintf(param_char, "%.10lf ", para_entry[i]); strcat(model_file,".c."); strcat(model_file,param_char); model_=FGM_train(&prob, ¶m); } else { int B = para_B[i]; param.B = B; sprintf(param_char, "%d ", param.B); printf("%d\n ", param.B); strcat(model_file,".B."); strcat(model_file,param_char); model_=FGM_train(&prob, ¶m); } printf("training is done!\n"); save_model_poly(model_file, model_); printf("model is saved!\n"); destroy_model(model_); if(model_->feature_pair>600) { break; } } } } if (n_flag==1) { delete []para_entry; } destroy_param(¶m); free(prob.y); free(prob.x); free(x_space); }
int main(int argc, char* argv[]) { char* path_to_config; char* path_to_errors; int is_batch_mode; int key = 0; int list_scr = 0; struct process_list* proc_list; screen_t* screen = NULL; int screen_num = 0; int q; int paranoia_level; /* Check OS to make sure we can run. */ paranoia_level = check(); init_options(&options); options.paranoia_level = paranoia_level; path_to_config = get_path_to_config(argc, argv); path_to_errors = get_path_to_error(argc, argv); is_batch_mode = get_batch_mode(argc, argv); init_errors(is_batch_mode, path_to_errors); q = read_config(path_to_config, &options); if (q == 0) { debug_printf("Config file successfully parsed.\n"); options.config_file = 1; } else debug_printf("Could not parse config file.\n"); /* Parse command line arguments. */ parse_command_line(argc, argv, &options, &list_scr, &screen_num); /* Add default screens */ if (options.default_screen == 1) init_screen(); /* Remove unused but declared counters */ tamp_counters(); if (list_scr) { list_screens(); delete_screens(); exit(0); } if (options.spawn_pos) { /* monitor only spawned process */ int child = spawn(argv + options.spawn_pos); options.only_pid = child; options.idle = 1; } do { if (screen_num >= 0) screen = get_screen(screen_num); else screen = get_screen_by_name(argv[-screen_num]); if (!screen) { fprintf(stderr, "No such screen.\n"); exit(EXIT_FAILURE); } /* initialize the list of processes, and then run */ proc_list = init_proc_list(); if (options.spawn_pos) { options.spawn_pos = 0; /* do this only once */ new_processes(proc_list, screen, &options); start_child(); } if (options.batch) { batch_mode(proc_list, screen); key = 'q'; } #ifdef HAVE_LIBCURSES else { key = live_mode(proc_list, screen); if ((key == '+') || (key == KEY_RIGHT)) { screen_num = (screen_num + 1) % get_num_screens(); active_col = 0; done_proc_list(proc_list); free(header); } if ((key == '-') || (key == KEY_LEFT)) { int n = get_num_screens(); screen_num = (screen_num + n - 1) % n; active_col = 0; done_proc_list(proc_list); free(header); } if ((key == 'u') || (key == 'K') || (key == 'p')) { done_proc_list(proc_list); } } #endif } while (key != 'q'); /* done, free memory (makes valgrind happy) */ close_error(); delete_screens(); done_proc_list(proc_list); free_options(&options); return 0; }
int main(int argc, char *argv[]) { log_options_t opts = LOG_OPTS_STDERR_ONLY; node_info_msg_t *node_info_ptr = NULL; node_info_msg_t *new_node_ptr = NULL; int error_code; int height = 40; int width = 100; int startx = 0; int starty = 0; int end = 0; int i; int rc; log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_DAEMON, NULL); parse_command_line(argc, argv); if (params.verbose) { opts.stderr_level += params.verbose; log_alter(opts, SYSLOG_FACILITY_USER, NULL); } if (params.cluster_dims == 4) { min_screen_width = 92; } else if (params.cluster_dims == 3) min_screen_width = 92; /* no need for this if you are resolving */ while (slurm_load_node((time_t) NULL, &new_node_ptr, SHOW_ALL)) { if (params.resolve || (params.display == COMMANDS)) { new_node_ptr = NULL; break; /* just continue */ } error_code = slurm_get_errno(); printf("slurm_load_node: %s\n", slurm_strerror(error_code)); if (params.iterate == 0) exit(1); sleep(10); /* keep trying to reconnect */ } select_g_ba_init(new_node_ptr, 0); if (dim_size == NULL) { dim_size = get_cluster_dims(new_node_ptr); if ((dim_size == NULL) || (dim_size[0] < 1)) fatal("Invalid system dimensions"); } _init_colors(); if (params.resolve) { char *ret_str = resolve_mp(params.resolve, new_node_ptr); if (ret_str) { printf("%s", ret_str); xfree(ret_str); } _smap_exit(0); /* Calls exit(), no return */ } if (!params.commandline) { int check_width = min_screen_width; initscr(); init_grid(new_node_ptr, COLS); signal(SIGWINCH, (void (*)(int))_resize_handler); if (params.cluster_dims == 4) { height = dim_size[2] * dim_size[3] + dim_size[2] + 3; width = (dim_size[1] + dim_size[3] + 1) * dim_size[0] + 2; check_width += width; } else if (params.cluster_dims == 3) { height = dim_size[1] * dim_size[2] + dim_size[1] + 3; width = dim_size[0] + dim_size[2] + 3; check_width += width; } else { height = 10; width = COLS; } if ((COLS < check_width) || (LINES < height)) { endwin(); error("Screen is too small make sure the screen " "is at least %dx%d\n" "Right now it is %dx%d\n", check_width, height, COLS, LINES); _smap_exit(1); /* Calls exit(), no return */ } raw(); keypad(stdscr, TRUE); noecho(); cbreak(); curs_set(0); nodelay(stdscr, TRUE); start_color(); _set_pairs(); grid_win = newwin(height, width, starty, startx); max_display = (getmaxy(grid_win) - 1) * (getmaxx(grid_win) - 1); if (params.cluster_dims == 4) { startx = width; COLS -= 2; width = COLS - width; height = LINES; } else if (params.cluster_dims == 3) { startx = width; COLS -= 2; width = COLS - width; height = LINES; } else { startx = 0; starty = height; height = LINES - height; } text_win = newwin(height, width, starty, startx); } while (!end) { if (!params.commandline) { _get_option(); redraw: clear_window(text_win); clear_window(grid_win); move(0, 0); update_grid(new_node_ptr); main_xcord = 1; main_ycord = 1; } if (!params.no_header) print_date(); clear_grid(); switch (params.display) { case JOBS: get_job(); break; case RESERVATIONS: get_reservation(); break; case SLURMPART: get_slurm_part(); break; case COMMANDS: #ifdef HAVE_BG wclear(text_win); get_command(); #else error("Must be on a real BG SYSTEM to " "run this command"); if (!params.commandline) endwin(); _smap_exit(1); /* Calls exit(), no return */ #endif break; case BGPART: if (params.cluster_flags & CLUSTER_FLAG_BG) get_bg_part(); else { error("Must be on a BG SYSTEM to " "run this command"); if (!params.commandline) endwin(); _smap_exit(1); /* Calls exit(), no return */ } break; } if (!params.commandline) { box(text_win, 0, 0); wnoutrefresh(text_win); print_grid(); box(grid_win, 0, 0); wnoutrefresh(grid_win); doupdate(); node_info_ptr = new_node_ptr; if (node_info_ptr) { error_code = slurm_load_node( node_info_ptr->last_update, &new_node_ptr, SHOW_ALL); if (error_code == SLURM_SUCCESS) slurm_free_node_info_msg( node_info_ptr); else if (slurm_get_errno() == SLURM_NO_CHANGE_IN_DATA) { error_code = SLURM_SUCCESS; new_node_ptr = node_info_ptr; } } else { error_code = slurm_load_node( (time_t) NULL, &new_node_ptr, SHOW_ALL); } if (error_code && (quiet_flag != 1)) { if (!params.commandline) { mvwprintw( text_win, main_ycord, 1, "slurm_load_node: %s", slurm_strerror( slurm_get_errno())); main_ycord++; } else { printf("slurm_load_node: %s", slurm_strerror( slurm_get_errno())); } } } if (params.iterate) { for (i = 0; i < params.iterate; i++) { sleep(1); if (!params.commandline) { if ((rc = _get_option()) == 1) goto redraw; else if (resize_screen) { resize_screen = 0; goto redraw; } } } } else break; } if (!params.commandline) { nodelay(stdscr, FALSE); getch(); endwin(); } _smap_exit(0); /* Calls exit(), no return */ exit(0); /* Redundant, but eliminates compiler warning */ }
int main(int argc, char **argv) { int i,j,num_runs=0,initial=0; int legend,spec2k6,num_benchmarks; char yaxis[]="Difference from Mean (log)"; parse_command_line(argc,argv, &num_runs,&initial, &legend,&spec2k6,&num_benchmarks); init_stats=calloc(sizeof(struct stats),num_benchmarks); machines=spec2k_machines; for(j=0;j<num_benchmarks;j++) { load_stats(num_runs,spec2k6,init_stats,argv[(j*2)+BENCH_START], argv[(j*2)+BENCH_START+1],"initial",j,FIXUP_NONE); } final_stats=calloc(sizeof(struct stats),num_benchmarks); for(j=0;j<num_benchmarks;j++) { load_stats(num_runs,spec2k6,final_stats,argv[(j*2)+BENCH_START], argv[(j*2)+BENCH_START+1],"final",j,FIXUP_ALL); } /* begin graph */ printf("(* Begin Graph *)\n"); printf("newgraph\n"); printf("\n(* Clipping *)\n"); printf("clip Y %.2f\n",3.0); /* don't print legend on side */ printf("\n(* Legend *)\n"); if (legend) { printf("legend custom\n"); } else { printf("legend off\n"); } #define WIDTH 16 #define HALF 8 #define OFFSET 2 #define LEGEND_XSCALE 12.0 #define LEGEND_YSCALE 1.25 /* y-axis */ printf("\n(* Y-Axis *)\n"); printf("yaxis size 2.25 min -10 max 10\n");//,max); printf("grid_gray 0.9 grid_lines\n"); printf("no_auto_hash_marks no_auto_hash_labels\n"); printf("label font Helvetica fontsize 14 x -%lf : %s\n", (double)num_benchmarks, yaxis); printf("hash_labels font Helvetica fontsize 14\n"); /* custom hash labels */ printf("hash_at 0 hash_label at 0 : 0\n"); printf("hash_at 2 hash_label at 2 : 100\n"); printf("hash_at 4 hash_label at 4 : 10K\n"); printf("hash_at 6 hash_label at 6 : 1M\n"); printf("hash_at 8 hash_label at 8 : 100M\n"); printf("hash_at 10 hash_label at 10 : 10B\n"); // printf("hash_at 12 hash_label at 12 : 1T\n"); printf("hash_at -2 hash_label at -2 : -100\n"); printf("hash_at -4 hash_label at -4 : -10K\n"); printf("hash_at -6 hash_label at -6 : -1M\n"); printf("hash_at -8 hash_label at -8 : -100M\n"); printf("hash_at -10 hash_label at -10 : -10B\n"); // printf("hash_at -12 hash_label at -12 : -1T\n"); /* x-axis */ printf("\n(* X-Axis *)\n"); printf("xaxis size 10 min 0 max %d\n",(num_benchmarks*WIDTH)); printf("grid_gray 0.5 grid_lines\n"); printf("no_auto_hash_marks no_auto_hash_labels\n"); printf("hash_labels hjr vjc rotate 25 font Helvetica fontsize 12\n"); /* custom hash labels */ for(i=0;i<num_benchmarks;i++) { // printf("hash_at %i hash_label at %i : %s.%s\n", printf("hash_label at %i : %s.%s\n", // (i*WIDTH)+HALF, (i*WIDTH)+HALF, argv[(i*2)+BENCH_START], argv[(i*2)+BENCH_START+1]); } /* only needed it +/- values? */ //printf("copygraph xaxis draw_at 0\n"); /* Title */ printf("\n(* Title *)\n"); // printf("newstring x 0 y %.2f hjl vjc\n",(max)+(max*0.1)); // printf("font Helvetica fontsize 14 : %s\n",title); printf("copygraph xaxis draw_at 0\n\n"); // Valid marks are: circle box diamond triangle x cross ellipse // general general_nf general_bez general_bez_nf postscript eps xbar ybar none text /* old */ if (!initial) { printf("\nnewcurve color 0.85 0.0 0.0 marktype xbar marksize %f " "label hjl vjc fontsize 12 font Helvetica x %lf y %lf : Original Standard Deviation\n", (double)(num_benchmarks*WIDTH)/BIGMARK_SCALE, 1.0,13.0); printf("pts\n"); for(i=0;i<num_benchmarks;i++) { if (init_stats[i].bench_stdev!=0.0) { printf("%d %.9f\n",(i*WIDTH)+HALF,log10(init_stats[i].bench_stdev)); } } printf("\nnewcurve color 0.85 0.0 0.0 marktype xbar marksize %f \n", (double)(num_benchmarks*WIDTH)/BIGMARK_SCALE); printf("pts\n"); for(i=0;i<num_benchmarks;i++) { if (init_stats[i].bench_stdev!=0.0) { printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(init_stats[i].bench_stdev)); } } } /* stdev */ printf("\nnewcurve color 0.85 0.85 0.85 marktype xbar marksize %f " "label hjl vjc fontsize 12 font Helvetica x %lf y %lf : Adjusted Standard Deviation\n", (double)(num_benchmarks*WIDTH)/SMALLMARK_SCALE, 1.0,12.0); printf("pts\n"); for(i=0;i<num_benchmarks;i++) { if (initial) { printf("%d %.9f\n",(i*WIDTH)+HALF,log10(init_stats[i].bench_stdev)); } else { printf("%d %.9f\n",(i*WIDTH)+HALF,log10(final_stats[i].bench_stdev)); } } printf("\nnewcurve color 0.85 0.85 0.85 marktype xbar marksize %f\n", (double)(num_benchmarks*WIDTH)/SMALLMARK_SCALE); printf("pts\n"); for(i=0;i<num_benchmarks;i++) { if (initial) { printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(init_stats[i].bench_stdev)); } else { printf("%d %.9f\n",(i*WIDTH)+HALF,-log10(final_stats[i].bench_stdev)); } } for(j=0;j<MAX_MACHINES;j++) { if (!(!machines[j].is_spec2k6&&spec2k6)) { printf("\nnewcurve color %s marktype text fontsize 12 font Helvetica-Bold : %s\n", machine_colors[j],machines[j].mark); printf("label hjl vjc fontsize 12 font Helvetica " "x %lf y %lf : %s\n", // num_benchmarks*0.7,max+max*0.1, ((double)((j/3)+1))*LEGEND_XSCALE+10.0, (((double)((3-(j%3))))*LEGEND_YSCALE)+10.5, machines[j].processor2); printf("pts\n"); for(i=0;i<num_benchmarks;i++) { double result; int valid; if (initial) { result=(double)(init_stats[i].machine_mean[j]-init_stats[i].bench_mean); valid=init_stats[i].machine_mean_valid[j]; } else { result=(double)(final_stats[i].machine_mean[j]-final_stats[i].bench_mean); valid=final_stats[i].machine_mean_valid[j]; } if (valid) { if (result<0.0) { printf("%d %.9f\n",(i*WIDTH)+j+OFFSET, -log10(fabs(result))); } else if (result>0.0) { printf("%d %.9f\n",(i*WIDTH)+j+OFFSET,log10(result)); } else { printf("%d 0.0\n",(i*WIDTH)+j+OFFSET); } } } } } return 0; }
main(int argc, char *argv[]) { /* * Purpose * ======= * * ZDRIVE is the main test program for the DOUBLE COMPLEX linear * equation driver routines ZGSSV and ZGSSVX. * * The program is invoked by a shell script file -- ztest.csh. * The output from the tests are written into a file -- ztest.out. * * ===================================================================== */ doublecomplex *a, *a_save; int *asub, *asub_save; int *xa, *xa_save; SuperMatrix A, B, X, L, U; SuperMatrix ASAV, AC; mem_usage_t mem_usage; int *perm_r; /* row permutation from partial pivoting */ int *perm_c, *pc_save; /* column permutation */ int *etree; doublecomplex zero = {0.0, 0.0}; double *R, *C; double *ferr, *berr; double *rwork; doublecomplex *wwork; void *work; int info, lwork, nrhs, panel_size, relax; int m, n, nnz; doublecomplex *xact; doublecomplex *rhsb, *solx, *bsav; int ldb, ldx; double rpg, rcond; int i, j, k1; double rowcnd, colcnd, amax; int maxsuper, rowblk, colblk; int prefact, nofact, equil, iequed; int nt, nrun, nfail, nerrs, imat, fimat, nimat; int nfact, ifact, itran; int kl, ku, mode, lda; int zerot, izero, ioff; double u; double anorm, cndnum; doublecomplex *Afull; double result[NTESTS]; superlu_options_t options; fact_t fact; trans_t trans; SuperLUStat_t stat; static char matrix_type[8]; static char equed[1], path[3], sym[1], dist[1]; /* Fixed set of parameters */ int iseed[] = {1988, 1989, 1990, 1991}; static char equeds[] = {'N', 'R', 'C', 'B'}; static fact_t facts[] = {FACTORED, DOFACT, SamePattern, SamePattern_SameRowPerm}; static trans_t transs[] = {NOTRANS, TRANS, CONJ}; /* Some function prototypes */ extern int zgst01(int, int, SuperMatrix *, SuperMatrix *, SuperMatrix *, int *, int *, double *); extern int zgst02(trans_t, int, int, int, SuperMatrix *, doublecomplex *, int, doublecomplex *, int, double *resid); extern int zgst04(int, int, doublecomplex *, int, doublecomplex *, int, double rcond, double *resid); extern int zgst07(trans_t, int, int, SuperMatrix *, doublecomplex *, int, doublecomplex *, int, doublecomplex *, int, double *, double *, double *); extern int zlatb4_(char *, int *, int *, int *, char *, int *, int *, double *, int *, double *, char *); extern int zlatms_(int *, int *, char *, int *, char *, double *d, int *, double *, double *, int *, int *, char *, doublecomplex *, int *, doublecomplex *, int *); extern int sp_zconvert(int, int, doublecomplex *, int, int, int, doublecomplex *a, int *, int *, int *); /* Executable statements */ strcpy(path, "ZGE"); nrun = 0; nfail = 0; nerrs = 0; /* Defaults */ lwork = 0; n = 1; nrhs = 1; panel_size = sp_ienv(1); relax = sp_ienv(2); u = 1.0; strcpy(matrix_type, "LA"); parse_command_line(argc, argv, matrix_type, &n, &panel_size, &relax, &nrhs, &maxsuper, &rowblk, &colblk, &lwork, &u); if ( lwork > 0 ) { work = SUPERLU_MALLOC(lwork); if ( !work ) { fprintf(stderr, "expert: cannot allocate %d bytes\n", lwork); exit (-1); } } /* Set the default input options. */ set_default_options(&options); options.DiagPivotThresh = u; options.PrintStat = NO; options.PivotGrowth = YES; options.ConditionNumber = YES; options.IterRefine = DOUBLE; if ( strcmp(matrix_type, "LA") == 0 ) { /* Test LAPACK matrix suite. */ m = n; lda = SUPERLU_MAX(n, 1); nnz = n * n; /* upper bound */ fimat = 1; nimat = NTYPES; Afull = doublecomplexCalloc(lda * n); zallocateA(n, nnz, &a, &asub, &xa); } else { /* Read a sparse matrix */ fimat = nimat = 0; zreadhb(&m, &n, &nnz, &a, &asub, &xa); } zallocateA(n, nnz, &a_save, &asub_save, &xa_save); rhsb = doublecomplexMalloc(m * nrhs); bsav = doublecomplexMalloc(m * nrhs); solx = doublecomplexMalloc(n * nrhs); ldb = m; ldx = n; zCreate_Dense_Matrix(&B, m, nrhs, rhsb, ldb, SLU_DN, SLU_Z, SLU_GE); zCreate_Dense_Matrix(&X, n, nrhs, solx, ldx, SLU_DN, SLU_Z, SLU_GE); xact = doublecomplexMalloc(n * nrhs); etree = intMalloc(n); perm_r = intMalloc(n); perm_c = intMalloc(n); pc_save = intMalloc(n); R = (double *) SUPERLU_MALLOC(m*sizeof(double)); C = (double *) SUPERLU_MALLOC(n*sizeof(double)); ferr = (double *) SUPERLU_MALLOC(nrhs*sizeof(double)); berr = (double *) SUPERLU_MALLOC(nrhs*sizeof(double)); j = SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs); rwork = (double *) SUPERLU_MALLOC(j*sizeof(double)); for (i = 0; i < j; ++i) rwork[i] = 0.; if ( !R ) ABORT("SUPERLU_MALLOC fails for R"); if ( !C ) ABORT("SUPERLU_MALLOC fails for C"); if ( !ferr ) ABORT("SUPERLU_MALLOC fails for ferr"); if ( !berr ) ABORT("SUPERLU_MALLOC fails for berr"); if ( !rwork ) ABORT("SUPERLU_MALLOC fails for rwork"); wwork = doublecomplexCalloc( SUPERLU_MAX(m,n) * SUPERLU_MAX(4,nrhs) ); for (i = 0; i < n; ++i) perm_c[i] = pc_save[i] = i; options.ColPerm = MY_PERMC; for (imat = fimat; imat <= nimat; ++imat) { /* All matrix types */ if ( imat ) { /* Skip types 5, 6, or 7 if the matrix size is too small. */ zerot = (imat >= 5 && imat <= 7); if ( zerot && n < imat-4 ) continue; /* Set up parameters with ZLATB4 and generate a test matrix with ZLATMS. */ zlatb4_(path, &imat, &n, &n, sym, &kl, &ku, &anorm, &mode, &cndnum, dist); zlatms_(&n, &n, dist, iseed, sym, &rwork[0], &mode, &cndnum, &anorm, &kl, &ku, "No packing", Afull, &lda, &wwork[0], &info); if ( info ) { printf(FMT3, "ZLATMS", info, izero, n, nrhs, imat, nfail); continue; } /* For types 5-7, zero one or more columns of the matrix to test that INFO is returned correctly. */ if ( zerot ) { if ( imat == 5 ) izero = 1; else if ( imat == 6 ) izero = n; else izero = n / 2 + 1; ioff = (izero - 1) * lda; if ( imat < 7 ) { for (i = 0; i < n; ++i) Afull[ioff + i] = zero; } else { for (j = 0; j < n - izero + 1; ++j) for (i = 0; i < n; ++i) Afull[ioff + i + j*lda] = zero; } } else { izero = 0; } /* Convert to sparse representation. */ sp_zconvert(n, n, Afull, lda, kl, ku, a, asub, xa, &nnz); } else { izero = 0; zerot = 0; } zCreate_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, SLU_Z, SLU_GE); /* Save a copy of matrix A in ASAV */ zCreate_CompCol_Matrix(&ASAV, m, n, nnz, a_save, asub_save, xa_save, SLU_NC, SLU_Z, SLU_GE); zCopy_CompCol_Matrix(&A, &ASAV); /* Form exact solution. */ zGenXtrue(n, nrhs, xact, ldx); StatInit(&stat); for (iequed = 0; iequed < 4; ++iequed) { *equed = equeds[iequed]; if (iequed == 0) nfact = 4; else nfact = 1; /* Only test factored, pre-equilibrated matrix */ for (ifact = 0; ifact < nfact; ++ifact) { fact = facts[ifact]; options.Fact = fact; for (equil = 0; equil < 2; ++equil) { options.Equil = equil; prefact = ( options.Fact == FACTORED || options.Fact == SamePattern_SameRowPerm ); /* Need a first factor */ nofact = (options.Fact != FACTORED); /* Not factored */ /* Restore the matrix A. */ zCopy_CompCol_Matrix(&ASAV, &A); if ( zerot ) { if ( prefact ) continue; } else if ( options.Fact == FACTORED ) { if ( equil || iequed ) { /* Compute row and column scale factors to equilibrate matrix A. */ zgsequ(&A, R, C, &rowcnd, &colcnd, &amax, &info); /* Force equilibration. */ if ( !info && n > 0 ) { if ( lsame_(equed, "R") ) { rowcnd = 0.; colcnd = 1.; } else if ( lsame_(equed, "C") ) { rowcnd = 1.; colcnd = 0.; } else if ( lsame_(equed, "B") ) { rowcnd = 0.; colcnd = 0.; } } /* Equilibrate the matrix. */ zlaqgs(&A, R, C, rowcnd, colcnd, amax, equed); } } if ( prefact ) { /* Need a factor for the first time */ /* Save Fact option. */ fact = options.Fact; options.Fact = DOFACT; /* Preorder the matrix, obtain the column etree. */ sp_preorder(&options, &A, perm_c, etree, &AC); /* Factor the matrix AC. */ zgstrf(&options, &AC, relax, panel_size, etree, work, lwork, perm_c, perm_r, &L, &U, &stat, &info); if ( info ) { printf("** First factor: info %d, equed %c\n", info, *equed); if ( lwork == -1 ) { printf("** Estimated memory: %d bytes\n", info - n); exit(0); } } Destroy_CompCol_Permuted(&AC); /* Restore Fact option. */ options.Fact = fact; } /* if .. first time factor */ for (itran = 0; itran < NTRAN; ++itran) { trans = transs[itran]; options.Trans = trans; /* Restore the matrix A. */ zCopy_CompCol_Matrix(&ASAV, &A); /* Set the right hand side. */ zFillRHS(trans, nrhs, xact, ldx, &A, &B); zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, bsav, ldb); /*---------------- * Test zgssv *----------------*/ if ( options.Fact == DOFACT && itran == 0) { /* Not yet factored, and untransposed */ zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, solx, ldx); zgssv(&options, &A, perm_c, perm_r, &L, &U, &X, &stat, &info); if ( info && info != izero ) { printf(FMT3, "zgssv", info, izero, n, nrhs, imat, nfail); } else { /* Reconstruct matrix from factors and compute residual. */ zgst01(m, n, &A, &L, &U, perm_c, perm_r, &result[0]); nt = 1; if ( izero == 0 ) { /* Compute residual of the computed solution. */ zCopy_Dense_Matrix(m, nrhs, rhsb, ldb, wwork, ldb); zgst02(trans, m, n, nrhs, &A, solx, ldx, wwork,ldb, &result[1]); nt = 2; } /* Print information about the tests that did not pass the threshold. */ for (i = 0; i < nt; ++i) { if ( result[i] >= THRESH ) { printf(FMT1, "zgssv", n, i, result[i]); ++nfail; } } nrun += nt; } /* else .. info == 0 */ /* Restore perm_c. */ for (i = 0; i < n; ++i) perm_c[i] = pc_save[i]; if (lwork == 0) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } } /* if .. end of testing zgssv */ /*---------------- * Test zgssvx *----------------*/ /* Equilibrate the matrix if fact = FACTORED and equed = 'R', 'C', or 'B'. */ if ( options.Fact == FACTORED && (equil || iequed) && n > 0 ) { zlaqgs(&A, R, C, rowcnd, colcnd, amax, equed); } /* Solve the system and compute the condition number and error bounds using zgssvx. */ zgssvx(&options, &A, perm_c, perm_r, etree, equed, R, C, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &mem_usage, &stat, &info); if ( info && info != izero ) { printf(FMT3, "zgssvx", info, izero, n, nrhs, imat, nfail); if ( lwork == -1 ) { printf("** Estimated memory: %.0f bytes\n", mem_usage.total_needed); exit(0); } } else { if ( !prefact ) { /* Reconstruct matrix from factors and compute residual. */ zgst01(m, n, &A, &L, &U, perm_c, perm_r, &result[0]); k1 = 0; } else { k1 = 1; } if ( !info ) { /* Compute residual of the computed solution.*/ zCopy_Dense_Matrix(m, nrhs, bsav, ldb, wwork, ldb); zgst02(trans, m, n, nrhs, &ASAV, solx, ldx, wwork, ldb, &result[1]); /* Check solution from generated exact solution. */ zgst04(n, nrhs, solx, ldx, xact, ldx, rcond, &result[2]); /* Check the error bounds from iterative refinement. */ zgst07(trans, n, nrhs, &ASAV, bsav, ldb, solx, ldx, xact, ldx, ferr, berr, &result[3]); /* Print information about the tests that did not pass the threshold. */ for (i = k1; i < NTESTS; ++i) { if ( result[i] >= THRESH ) { printf(FMT2, "zgssvx", options.Fact, trans, *equed, n, imat, i, result[i]); ++nfail; } } nrun += NTESTS; } /* if .. info == 0 */ } /* else .. end of testing zgssvx */ } /* for itran ... */ if ( lwork == 0 ) { Destroy_SuperNode_Matrix(&L); Destroy_CompCol_Matrix(&U); } } /* for equil ... */ } /* for ifact ... */ } /* for iequed ... */ #if 0 if ( !info ) { PrintPerf(&L, &U, &mem_usage, rpg, rcond, ferr, berr, equed); } #endif } /* for imat ... */ /* Print a summary of the results. */ PrintSumm("ZGE", nfail, nrun, nerrs); SUPERLU_FREE (rhsb); SUPERLU_FREE (bsav); SUPERLU_FREE (solx); SUPERLU_FREE (xact); SUPERLU_FREE (etree); SUPERLU_FREE (perm_r); SUPERLU_FREE (perm_c); SUPERLU_FREE (pc_save); SUPERLU_FREE (R); SUPERLU_FREE (C); SUPERLU_FREE (ferr); SUPERLU_FREE (berr); SUPERLU_FREE (rwork); SUPERLU_FREE (wwork); Destroy_SuperMatrix_Store(&B); Destroy_SuperMatrix_Store(&X); Destroy_CompCol_Matrix(&A); Destroy_CompCol_Matrix(&ASAV); if ( lwork > 0 ) { SUPERLU_FREE (work); Destroy_SuperMatrix_Store(&L); Destroy_SuperMatrix_Store(&U); } StatFree(&stat); return 0; }
// Interface function of matlab // now assume prhs[0]: label prhs[1]: features void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { const char *error_msg; // fix random seed to have same results for each run // (for cross validation and probability estimation) srand(1); // Transform the input Matrix to libsvm format if(nrhs > 0 && nrhs < 4) { int err; if(!mxIsDouble(prhs[0]) || !mxIsDouble(prhs[1])) { mexPrintf("Error: label vector and instance matrix must be double\n"); fake_answer(plhs); return; } if(parse_command_line(nrhs, prhs, NULL)) { exit_with_help(); svm_destroy_param(¶m); fake_answer(plhs); return; } if(mxIsSparse(prhs[1])) { if(param.kernel_type == PRECOMPUTED) { // precomputed kernel requires dense matrix, so we make one mxArray *rhs[1], *lhs[1]; rhs[0] = mxDuplicateArray(prhs[1]); if(mexCallMATLAB(1, lhs, 1, rhs, "full")) { mexPrintf("Error: cannot generate a full training instance matrix\n"); svm_destroy_param(¶m); fake_answer(plhs); return; } err = read_problem_dense(prhs[0], lhs[0]); mxDestroyArray(lhs[0]); mxDestroyArray(rhs[0]); } else err = read_problem_sparse(prhs[0], prhs[1]); } else err = read_problem_dense(prhs[0], prhs[1]); // svmtrain's original code error_msg = svm_check_parameter(&prob, ¶m); if(err || error_msg) { if (error_msg != NULL) mexPrintf("Error: %s\n", error_msg); svm_destroy_param(¶m); free(prob.y); free(prob.x); free(x_space); fake_answer(plhs); return; } if(cross_validation) { double *ptr; plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL); ptr = mxGetPr(plhs[0]); ptr[0] = do_cross_validation(); } else { int nr_feat = mxGetN(prhs[1]); const char *error_msg; model = svm_train(&prob, ¶m); error_msg = model_to_matlab_structure(plhs, nr_feat, model); if(error_msg) mexPrintf("Error: can't convert libsvm model to matrix structure: %s\n", error_msg); svm_destroy_model(model); } svm_destroy_param(¶m); free(prob.y); free(prob.x); free(x_space); } else { exit_with_help(); fake_answer(plhs); return; } }
int main (int argc, char *argv[]) { char *prio_type = NULL; int error_code = SLURM_SUCCESS; priority_factors_request_msg_t req_msg; priority_factors_response_msg_t *resp_msg = NULL; log_options_t opts = LOG_OPTS_STDERR_ONLY ; slurm_conf_init(NULL); log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL); parse_command_line( argc, argv ); if (params.verbose) { opts.stderr_level += params.verbose; log_alter(opts, SYSLOG_FACILITY_USER, NULL); } if (working_cluster_rec) { slurm_ctl_conf_info_msg_t *slurm_ctl_conf_ptr; error_code = slurm_load_ctl_conf((time_t) NULL, &slurm_ctl_conf_ptr); if (error_code) { slurm_perror ("slurm_load_ctl_conf error"); exit(error_code); } weight_age = slurm_ctl_conf_ptr->priority_weight_age; weight_fs = slurm_ctl_conf_ptr->priority_weight_fs; weight_js = slurm_ctl_conf_ptr->priority_weight_js; weight_part = slurm_ctl_conf_ptr->priority_weight_part; weight_qos = slurm_ctl_conf_ptr->priority_weight_qos; prio_type = xstrdup(slurm_ctl_conf_ptr->priority_type); slurm_free_ctl_conf(slurm_ctl_conf_ptr); } else { weight_age = slurm_get_priority_weight_age(); weight_fs = slurm_get_priority_weight_fairshare(); weight_js = slurm_get_priority_weight_job_size(); weight_part = slurm_get_priority_weight_partition(); weight_qos = slurm_get_priority_weight_qos(); prio_type = slurm_get_priority_type(); } /* Check to see if we are running a supported accounting plugin */ if (strncasecmp(prio_type, "priority/multifactor", 20)) { fprintf (stderr, "You are not running a supported " "priority plugin\n(%s).\n" "Only 'priority/multifactor' and " "'priority/multifactor2' are supported.\n", prio_type); exit(1); } xfree(prio_type); memset(&req_msg, 0, sizeof(priority_factors_request_msg_t)); if (params.jobs) req_msg.job_id_list = params.job_list; else req_msg.job_id_list = NULL; if (params.users) req_msg.uid_list = params.user_list; else req_msg.uid_list = NULL; error_code = _get_info(&req_msg, &resp_msg); if (error_code) { slurm_perror("Couldn't get priority factors from controller"); exit(error_code); } if (params.format == NULL) { if (params.normalized) { if (params.long_list) params.format = "%.7i %.8u %10y %10a %10f %10j " "%10p %10q"; else{ params.format = xstrdup("%.7i"); if (params.users) xstrcat(params.format, " %.8u"); xstrcat(params.format, " %10y"); if (weight_age) xstrcat(params.format, " %10a"); if (weight_fs) xstrcat(params.format, " %10f"); if (weight_js) xstrcat(params.format, " %10j"); if (weight_part) xstrcat(params.format, " %10p"); if (weight_qos) xstrcat(params.format, " %10q"); } } else { if (params.long_list) params.format = "%.7i %.8u %.10Y %.10A %.10F " "%.10J %.10P %.10Q %.6N"; else{ params.format = xstrdup("%.7i"); if (params.users) xstrcat(params.format, " %.8u"); xstrcat(params.format, " %.10Y"); if (weight_age) xstrcat(params.format, " %.10A"); if (weight_fs) xstrcat(params.format, " %.10F"); if (weight_js) xstrcat(params.format, " %.10J"); if (weight_part) xstrcat(params.format, " %.10P"); if (weight_qos) xstrcat(params.format, " %.10Q"); } } } /* create the format list from the format */ parse_format(params.format); if (params.jobs && (!resp_msg || !resp_msg->priority_factors_list || !list_count(resp_msg->priority_factors_list))) { printf("Unable to find jobs matching user/id(s) specified\n"); } else if (resp_msg) { print_jobs_array(resp_msg->priority_factors_list, params.format_list); } #if 0 /* Free storage here if we want to verify that logic. * Since we exit next, this is not important */ list_destroy(params.format_list); slurm_free_priority_factors_response_msg(resp_msg); #endif exit (error_code); }
int main(int argc, char **argv) { ListIterator itr = NULL; uint32_t req_cpufreq_min = NO_VAL; uint32_t req_cpufreq_max = NO_VAL; uint32_t req_cpufreq_gov = NO_VAL; uint32_t stepid = NO_VAL; slurmdb_selected_step_t *selected_step = NULL; #ifdef HAVE_ALPS_CRAY error("The sstat command is not supported on Cray systems"); return 1; #endif #ifdef HAVE_BG error("The sstat command is not supported on IBM BlueGene systems"); return 1; #endif slurm_conf_init(NULL); print_fields_list = list_create(NULL); print_fields_itr = list_iterator_create(print_fields_list); parse_command_line(argc, argv); if (!params.opt_job_list || !list_count(params.opt_job_list)) { error("You didn't give me any jobs to stat."); return 1; } print_fields_header(print_fields_list); itr = list_iterator_create(params.opt_job_list); while ((selected_step = list_next(itr))) { char *nodelist = NULL; bool free_nodelist = false; if (selected_step->stepid == INFINITE) { /* get the batch step info */ job_info_msg_t *job_ptr = NULL; hostlist_t hl; if (slurm_load_job( &job_ptr, selected_step->jobid, SHOW_ALL)) { error("couldn't get info for job %u", selected_step->jobid); continue; } stepid = NO_VAL; hl = hostlist_create(job_ptr->job_array[0].nodes); nodelist = hostlist_pop(hl); free_nodelist = true; hostlist_destroy(hl); slurm_free_job_info_msg(job_ptr); } else if (selected_step->stepid != NO_VAL) { stepid = selected_step->stepid; } else if (params.opt_all_steps) { job_step_info_response_msg_t *step_ptr = NULL; int i = 0; if (slurm_get_job_steps( 0, selected_step->jobid, NO_VAL, &step_ptr, SHOW_ALL)) { error("couldn't get steps for job %u", selected_step->jobid); continue; } for (i = 0; i < step_ptr->job_step_count; i++) { _do_stat(selected_step->jobid, step_ptr->job_steps[i].step_id, step_ptr->job_steps[i].nodes, step_ptr->job_steps[i].cpu_freq_min, step_ptr->job_steps[i].cpu_freq_max, step_ptr->job_steps[i].cpu_freq_gov); } slurm_free_job_step_info_response_msg(step_ptr); continue; } else { /* get the first running step to query against. */ job_step_info_response_msg_t *step_ptr = NULL; if (slurm_get_job_steps( 0, selected_step->jobid, NO_VAL, &step_ptr, SHOW_ALL)) { error("couldn't get steps for job %u", selected_step->jobid); continue; } if (!step_ptr->job_step_count) { error("no steps running for job %u", selected_step->jobid); continue; } stepid = step_ptr->job_steps[0].step_id; nodelist = step_ptr->job_steps[0].nodes; req_cpufreq_min = step_ptr->job_steps[0].cpu_freq_min; req_cpufreq_max = step_ptr->job_steps[0].cpu_freq_max; req_cpufreq_gov = step_ptr->job_steps[0].cpu_freq_gov; } _do_stat(selected_step->jobid, stepid, nodelist, req_cpufreq_min, req_cpufreq_max, req_cpufreq_gov); if (free_nodelist && nodelist) free(nodelist); } list_iterator_destroy(itr); xfree(params.opt_field_list); if (params.opt_job_list) list_destroy(params.opt_job_list); if (print_fields_itr) list_iterator_destroy(print_fields_itr); if (print_fields_list) list_destroy(print_fields_list); return 0; }