/************************************************************************ * * * MAIN PROGRAM. * * */ main(int argc, char **argv) { char infile[128]; /* input filename */ char outfile[128]; /* output filename */ float ratio_wd=1.0; /* ratio for image width */ float ratio_ht=1.0; /* ratio for image height */ Sid = Sid; if (argc == 2) { /* Check if input file is sisfile */ if (check_sisfile(argv[1]) == OK) exit(0); (void)strcpy(infile, argv[1]); (void)sprintf(outfile, "%s.sis", infile); } else if ((argc == 3) || (argc == 5)) { (void)strcpy(infile, argv[1]); (void)strcpy(outfile, argv[2]); if (argc == 5) { if (sscanf(argv[3], "%f", &ratio_wd) != 1) usage_info(argv); if (sscanf(argv[4], "%f", &ratio_ht) != 1) usage_info(argv); /* Make sure one of the proprotional ratio is 1.0 */ if (ratio_wd > ratio_ht) { ratio_wd /= ratio_ht; ratio_ht = 1.0; } else { ratio_ht /= ratio_wd; ratio_wd = 1.0; } } } else usage_info(argv); fprintf(stderr," Converting %s to %s begins ......", infile, outfile); convert_phase2sis(infile, outfile, ratio_wd, ratio_ht); fprintf(stderr," Done.\n"); exit(0); }
static int check_parameters(void) { if (g>3) { if (word[1][0]=='?') { usage_info(); return -1; } } else { usage_info(); return -1; } return 1; }
int main(int argc, char **argv) { int i; int result = 1; if(argc == 1) { version_info(); usage_info(); return EXIT_SUCCESS; } for(i=1; i<argc; i++) if(result) result = process_file(argv[i]); if(result) return EXIT_SUCCESS; else return EXIT_FAILURE; }
int main(int argc, char * const *argv) { if (argc < 2) { usage(); return 0; } const char *command = argv[1]; if (strcmp(command, "info") == 0) { if (argc < 3) { usage_info(); return 1; } return info(argc - 2, argv + 2); } else if (strcmp(command, "get") == 0) { if (argc < 4) { usage_get(); return 1; } const char *index_filename = argv[2]; char *log_filename = sparkey_create_log_filename(index_filename); if (log_filename == NULL) { fprintf(stderr, "index filename must end with .spi\n"); return 1; } int retval = get(argv[2], log_filename, argv[3]); free(log_filename); return retval; } else if (strcmp(command, "writehash") == 0) { if (argc < 3) { usage_writehash(); return 1; } const char *log_filename = argv[2]; char *index_filename = sparkey_create_index_filename(log_filename); if (index_filename == NULL) { fprintf(stderr, "log filename must end with .spl\n"); return 1; } int retval = writehash(index_filename, log_filename); free(index_filename); return retval; } else if (strcmp(command, "createlog") == 0) { opterr = 0; optind = 2; int opt_char; int block_size = SNAPPY_DEFAULT_BLOCKSIZE; sparkey_compression_type compression_type = SPARKEY_COMPRESSION_NONE; while ((opt_char = getopt (argc, argv, "b:c:")) != -1) { switch (opt_char) { case 'b': if (sscanf(optarg, "%d", &block_size) != 1) { fprintf(stderr, "Block size must be an integer, but was '%s'\n", optarg); return 1; } if (block_size > SNAPPY_MAX_BLOCKSIZE || block_size < SNAPPY_MIN_BLOCKSIZE) { fprintf(stderr, "Block size %d, not in range. Max is %d, min is %d\n", block_size, SNAPPY_MAX_BLOCKSIZE, SNAPPY_MIN_BLOCKSIZE); return 1; } break; case 'c': if (strcmp(optarg, "none") == 0) { compression_type = SPARKEY_COMPRESSION_NONE; } else if (strcmp(optarg, "snappy") == 0) { compression_type = SPARKEY_COMPRESSION_SNAPPY; } else { fprintf(stderr, "Invalid compression type: '%s'\n", optarg); return 1; } break; case '?': if (optopt == 'b' || optopt == 'c') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else if (isprint(optopt)) { fprintf(stderr, "Unknown option '-%c'.\n", optopt); } else { fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt); } return 1; default: fprintf(stderr, "Unknown option parsing failure\n"); return 1; } } if (optind >= argc) { usage_createlog(); return 1; } const char *log_filename = argv[optind]; sparkey_logwriter *writer; assert(sparkey_logwriter_create(&writer, log_filename, compression_type, block_size)); assert(sparkey_logwriter_close(&writer)); return 0; } else if (strcmp(command, "appendlog") == 0) { opterr = 0; optind = 2; int opt_char; char delimiter = '\t'; while ((opt_char = getopt (argc, argv, "d:")) != -1) { switch (opt_char) { case 'd': if (strlen(optarg) != 1) { fprintf(stderr, "delimiter must be one character, but was '%s'\n", optarg); return 1; } delimiter = optarg[0]; break; case '?': if (optopt == 'd') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else if (isprint(optopt)) { fprintf(stderr, "Unknown option '-%c'.\n", optopt); } else { fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt); } return 1; default: fprintf(stderr, "Unknown option parsing failure\n"); return 1; } } if (optind >= argc) { usage_appendlog(); return 1; } const char *log_filename = argv[optind]; sparkey_logwriter *writer; assert(sparkey_logwriter_append(&writer, log_filename)); int rc = append(writer, delimiter, stdin); assert(sparkey_logwriter_close(&writer)); return rc; } else if (strcmp(command, "help") == 0 || strcmp(command, "--help") == 0 || strcmp(command, "-h") == 0) { usage(); return 0; } else { fprintf(stderr, "Unknown command: %s\n", command); return 1; } }
int exec_info(int argc, char **argv) { struct pkgdb *db = NULL; struct pkgdb_it *it = NULL; int query_flags; struct pkg *pkg = NULL; uint64_t opt = INFO_TAG_NAMEVER; match_t match = MATCH_GLOB; char *pkgname; char *pkgversion = NULL, *pkgversion2 = NULL; const char *file = NULL; int ch, fd; int ret = EPKG_OK; int retcode = 0; bool gotone = false; int i, j; int sign = 0; int sign2 = 0; int open_flags = 0; bool pkg_exists = false; bool origin_search = false; bool e_flag = false; struct pkg_manifest_key *keys = NULL; #ifdef HAVE_CAPSICUM cap_rights_t rights; #endif struct option longopts[] = { { "all", no_argument, NULL, 'a' }, { "annotations", no_argument, NULL, 'A' }, { "provided-shlibs", no_argument, NULL, 'b' }, { "required-shlibs", no_argument, NULL, 'B' }, { "case-sensitive", no_argument, NULL, 'C' }, { "dependencies", no_argument, NULL, 'd' }, { "pkg-message", no_argument, NULL, 'D' }, { "exists", no_argument, NULL, 'e' }, { "show-name-only", no_argument, NULL, 'E' }, { "full", no_argument, NULL, 'f' }, { "file", required_argument, NULL, 'F' }, { "glob", no_argument, NULL, 'g' }, { "case-insensitive", no_argument, NULL, 'i' }, { "comment", no_argument, NULL, 'I' }, { "locked", no_argument, NULL, 'k' }, { "list-files", no_argument, NULL, 'l' }, { "origin", no_argument, NULL, 'o' }, { "by-origin", no_argument, NULL, 'O' }, { "prefix", no_argument, NULL, 'p' }, { "quiet", no_argument, NULL, 'q' }, { "required-by", no_argument, NULL, 'r' }, { "raw", no_argument, NULL, 'R' }, { "size", no_argument, NULL, 's' }, { "regex", no_argument, NULL, 'x' }, { "raw-format", required_argument, NULL, 1 }, { NULL, 0, NULL, 0 }, }; /* TODO: exclusive opts ? */ while ((ch = getopt_long(argc, argv, "+aAbBCdDeEfF:giIkloOpqrRsx", longopts, NULL)) != -1) { switch (ch) { case 'a': match = MATCH_ALL; break; case 'A': opt |= INFO_ANNOTATIONS; break; case 'b': opt |= INFO_SHLIBS_PROVIDED; break; case 'B': opt |= INFO_SHLIBS_REQUIRED; break; case 'C': pkgdb_set_case_sensitivity(true); break; case 'd': opt |= INFO_DEPS; break; case 'D': opt |= INFO_MESSAGE; break; case 'e': pkg_exists = true;; retcode = 1; break; case 'E': /* ports compatibility */ e_flag = true; break; case 'f': opt |= INFO_FULL; break; case 'F': file = optarg; break; case 'g': match = MATCH_GLOB; break; case 'i': pkgdb_set_case_sensitivity(false); break; case 'I': opt |= INFO_COMMENT; break; case 'k': opt |= INFO_LOCKED; break; case 'l': opt |= INFO_FILES; break; case 'o': opt |= INFO_ORIGIN; break; case 'O': origin_search = true; /* only for ports compat */ break; case 'p': opt |= INFO_PREFIX; break; case 'q': quiet = true; break; case 'r': opt |= INFO_RDEPS; break; case 'R': opt |= INFO_RAW; break; case 's': opt |= INFO_FLATSIZE; break; case 'x': match = MATCH_REGEX; break; case 1: if (strcasecmp(optarg, "json") == 0) opt |= INFO_RAW_JSON; else if (strcasecmp(optarg, "json-compact") == 0) opt |= INFO_RAW_JSON_COMPACT; else if (strcasecmp(optarg, "yaml") == 0) opt |= INFO_RAW_YAML; else if (strcasecmp(optarg, "ucl") == 0) opt |= INFO_RAW_UCL; else errx(EX_USAGE, "Invalid format '%s' for the " "raw output, expecting json, json-compact " "or yaml", optarg); break; default: usage_info(); return(EX_USAGE); } } if (argc == 1 || (argc == 2 && quiet)) match = MATCH_ALL; argc -= optind; argv += optind; if (argc == 0 && file == NULL && match != MATCH_ALL) { /* which -O bsd.*.mk always execpt clean output */ if (origin_search) return (EX_OK); usage_info(); return (EX_USAGE); } /* When no other data is requested, default is to print * 'name-ver comment' For -O, just print name-ver */ if (!origin_search && (opt & INFO_ALL) == 0 && match == MATCH_ALL && !quiet) opt |= INFO_COMMENT; /* Special compatibility: handle -O and -q -O */ if (origin_search) { if (quiet) { opt = INFO_TAG_NAMEVER; quiet = false; } else { opt = INFO_TAG_NAMEVER|INFO_COMMENT; } } if (match == MATCH_ALL && opt == INFO_TAG_NAMEVER) quiet = false; if (file != NULL) { if ((fd = open(file, O_RDONLY)) == -1) { warn("Unable to open %s", file); return (EX_IOERR); } #ifdef HAVE_CAPSICUM cap_rights_init(&rights, CAP_READ, CAP_FSTAT); if (cap_rights_limit(fd, &rights) < 0 && errno != ENOSYS ) { warn("cap_rights_limit() failed"); close(fd); return (EX_SOFTWARE); } if (cap_enter() < 0 && errno != ENOSYS) { warn("cap_enter() failed"); close(fd); return (EX_SOFTWARE); } #endif if (opt == INFO_TAG_NAMEVER) opt |= INFO_FULL; pkg_manifest_keys_new(&keys); if (opt & INFO_RAW) { if ((opt & (INFO_RAW_JSON|INFO_RAW_JSON_COMPACT|INFO_RAW_UCL)) == 0) opt |= INFO_RAW_YAML; } if ((opt & (INFO_RAW | INFO_FILES | INFO_DIRS)) == 0) open_flags = PKG_OPEN_MANIFEST_COMPACT; if (pkg_open_fd(&pkg, fd, keys, open_flags) != EPKG_OK) { close(fd); return (1); } pkg_manifest_keys_free(keys); print_info(pkg, opt); close(fd); pkg_free(pkg); return (EX_OK); } ret = pkgdb_access(PKGDB_MODE_READ, PKGDB_DB_LOCAL); if (ret == EPKG_ENOACCESS) { warnx("Insufficient privileges to query the package database"); return (EX_NOPERM); } else if (ret == EPKG_ENODB) { if (match == MATCH_ALL) return (EX_OK); if (origin_search) return (EX_OK); if (!quiet) warnx("No packages installed"); return (EX_UNAVAILABLE); } else if (ret != EPKG_OK) return (EX_IOERR); ret = pkgdb_open(&db, PKGDB_DEFAULT); if (ret != EPKG_OK) return (EX_IOERR); if (pkgdb_obtain_lock(db, PKGDB_LOCK_READONLY) != EPKG_OK) { pkgdb_close(db); warnx("Cannot get a read lock on a database, it is locked by another process"); return (EX_TEMPFAIL); } i = 0; do { gotone = false; pkgname = argv[i]; /* * allow to search for origin with a trailing / * likes audio/linux-vsound depending on ${PORTSDIR}/audio/sox/ */ if (argc > 0 && pkgname[strlen(pkgname) -1] == '/') pkgname[strlen(pkgname) -1] = '\0'; if (argc > 0) { j=0; while (pkgname[j] != '\0') { if (pkgname[j] == '<') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = LT; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=LE; j++; } } else { pkgversion = pkgname + j; sign = LT; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=LE; j++; } } } else if (pkgname[j] == '>') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = GT; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=GE; j++; } } else { pkgversion = pkgname + j; sign = GT; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=GE; j++; } } } else if (pkgname[j] == '=') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = EQ; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=EQ; j++; } } else { pkgversion = pkgname + j; sign = EQ; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=EQ; j++; } } } j++; } } if (match != MATCH_ALL && pkgname[0] == '\0') { fprintf(stderr, "Pattern must not be empty.\n"); i++; continue; } if ((it = pkgdb_query(db, pkgname, match)) == NULL) { goto cleanup; } /* this is place for compatibility hacks */ /* ports infrastructure expects pkg info -q -O to * always return 0 even if the ports doesn't exists */ if (origin_search) gotone = true; /* end of compatibility hacks */ /* * only show full version in case of match glob with a * single argument specified which does not contains * any glob pattern */ if (argc == 1 && !origin_search && !quiet && !e_flag && match == MATCH_GLOB && strcspn(pkgname, "*[]{}()") == strlen(pkgname) && opt == INFO_TAG_NAMEVER) opt |= INFO_FULL; query_flags = info_flags(opt, false); while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) { gotone = true; const char *version; pkg_get(pkg, PKG_VERSION, &version); if (pkgversion != NULL) { switch (pkg_version_cmp(version, pkgversion)) { case -1: if (sign != LT && sign != LE) { gotone = false; continue; } break; case 0: if (sign != LE && sign != GE && sign != EQ) { gotone = false; continue; } break; case 1: if (sign != GT && sign != GE) { gotone = false; continue; } break; } } if (pkgversion2 != NULL) { switch (pkg_version_cmp(version, pkgversion2)) { case -1: if (sign2 != LT && sign2 != LE) { gotone = false; continue; } break; case 0: if (sign2 != LE && sign2 != GE && sign2 != EQ) { gotone = false; continue; } break; case 1: if (sign2 != GT && sign2 != GE) { gotone = false; continue; } break; } } if (pkg_exists) retcode = EX_OK; else print_info(pkg, opt); } if (ret != EPKG_END) { retcode = EX_IOERR; } if (retcode == EX_OK && !gotone && match != MATCH_ALL) { if (!quiet) warnx("No package(s) matching %s", argv[i]); retcode = EX_SOFTWARE; } pkgdb_it_free(it); i++; } while (i < argc); cleanup: pkg_free(pkg); pkgdb_release_lock(db, PKGDB_LOCK_READONLY); pkgdb_close(db); return (retcode); }
int main(int argc, char *argv[]){ int i,j,k; int _vector_size = VECTOR_SIZE; int _iteration = ITERATION; double _initval = INITVAL; int _column = VECTOR_SIZE+1; int ans_index=0; int change=1; double computing; double *matrix; double *ans[2];// in start ,0 is old , 1 is new,but it's will change in running time; double time; FILE *file; // processing argument if(argc > 1){ for( i = 1 ; i < argc ;){ if( !strcmp(argv[i], "-s" )){ if(argv[i+1] == NULL){ usage_info(); return 0; } _vector_size = atoi(argv[i+1]); _column = _vector_size + 1; i+=2; } else if( !strcmp(argv[i], "-i")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _iteration = atoi(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-v")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _initval = atof(argv[i+1]); i+=2; } else{ usage_info(); return 0; } } } srand( RANDOM_SEED ); // init value matrix = (double*) malloc( sizeof(double) * _vector_size * _column ); ans[0] = (double*) malloc( sizeof(double) * _vector_size ); ans[1] = (double*) malloc( sizeof(double) * _vector_size ); for( i=0; i < _vector_size; i++){ ans[0][i] = _initval; for( j=0; j< _column ; j++){ if(i == j) matrix[i*_column + j] = 0; else matrix[i*_column + j] = create_init_value(); } // matrix[i*_column + j] =1 ; } /* for( i=0; i < _vector_size; i++){ for( j=0; j< _column ; j++){ printf("%f ", matrix[i*_column + j]); } printf("\n"); } */ /* ans[0][0]=-1.5; ans[0][1]=2.5; ans[0][2]=-0.5; matrix[0]=-0; matrix[1]=-0.125; matrix[2]=0.25; matrix[3]=-(double)11/8; matrix[_column]=-(double)2/9; matrix[_column+1]=0; matrix[_column+2]=-(double)1/9; matrix[_column+3]=(double)22/9; matrix[2*_column]=(double)1/11; matrix[2*_column+1]=(double)2/11; matrix[2*_column+2]=0; matrix[2*_column+3]=-(double)15/11; */ /* * jacobi method computing */ time = -d2mce_mtime(); for( i=0; i<_iteration; i++){ for( j=0; j<_vector_size; j++){ //computing = matrix[i*_column + _vector_size]; computing =0; for( k=0; k<_vector_size; k++){ if(j!=k) computing += matrix[j*_column + k]*ans[ans_index][k]; } computing += matrix[j*_column + _vector_size]; ans[ans_index + change][j] = computing; printf ("%d ", computing); } printf("\n"); ans_index += change; // for( j=0; j<_vector_size; j++){ // printf("%f ", ans[ans_index][j]); // } // printf("\n"); change = -change; } time += d2mce_mtime(); /* * print the result information */ printf("the ans:\n"); for( i=0; i < _vector_size; i++){ printf("%f ", ans[ans_index][i]); } printf("Result:\n"); printf("\tTIME\tVector_Size\n"); printf("\t%f\t%d\n", time, _vector_size); file = fopen("sequence_output.data","w"); fwrite(ans[ans_index], sizeof(double), _vector_size, file); fclose(file); return 0; }
int exec_info(int argc, char **argv) { struct pkgdb *db = NULL; struct pkgdb_it *it = NULL; int query_flags; struct pkg *pkg = NULL; unsigned int opt = INFO_TAG_NAMEVER; match_t match = MATCH_EXACT; char *pkgname; char *pkgversion = NULL, *pkgversion2 = NULL; const char *file = NULL; int ch; int ret = EPKG_OK; int retcode = 0; bool gotone = false; int i, j; int sign = 0; int sign2 = 0; bool pkg_exists = false; bool origin_search = false; /* TODO: exclusive opts ? */ while ((ch = getopt(argc, argv, "aDegxEIdrklBsqopOfF:R")) != -1) { switch (ch) { case 'a': match = MATCH_ALL; break; case 'O': origin_search = true; /* only for ports compat */ break; case 'e': pkg_exists = true;; retcode = 1; break; case 'g': match = MATCH_GLOB; break; case 'x': match = MATCH_REGEX; break; case 'D': opt |= INFO_MESSAGE; break; case 'd': opt |= INFO_DEPS; break; case 'I': opt |= INFO_COMMENT; break; case 'r': opt |= INFO_RDEPS; break; case 'k': opt |= INFO_LOCKED; break; case 'l': opt |= INFO_FILES; break; case 'B': opt |= INFO_SHLIBS; break; case 's': opt |= INFO_FLATSIZE; break; case 'E': /* ports compatibility */ /* FALLSTHROUGH */ case 'q': quiet = true; break; case 'o': opt |= INFO_ORIGIN; break; case 'p': opt |= INFO_PREFIX; break; case 'f': opt |= INFO_FULL; break; case 'F': file = optarg; break; case 'R': opt |= INFO_RAW; break; default: usage_info(); return(EX_USAGE); } } if (argc == 1) match = MATCH_ALL; argc -= optind; argv += optind; if (argc == 0 && file == NULL && match != MATCH_ALL) { /* which -O bsd.*.mk always execpt clean output */ if (origin_search) return (EX_OK); usage_info(); return (EX_USAGE); } /* When no other data is requested, default is to print * 'name-ver comment' For -O, just print name-ver */ if (!origin_search && (opt & INFO_ALL) == 0 && match == MATCH_ALL && !quiet) opt |= INFO_COMMENT; /* Special compatibility: handle -O and -q -O */ if (origin_search) { if (quiet) { opt = INFO_TAG_NAMEVER; quiet = false; } else { opt = INFO_TAG_NAMEVER|INFO_COMMENT; } } if (match == MATCH_ALL && opt == INFO_TAG_NAMEVER) quiet = false; if (file != NULL) { if (pkg_open(&pkg, file) != EPKG_OK) { return (1); } print_info(pkg, opt); pkg_free(pkg); return (0); } ret = pkgdb_open(&db, PKGDB_DEFAULT); if (ret == EPKG_ENODB) { if (geteuid() == 0) return (EX_IOERR); if (match == MATCH_ALL) return (EX_OK); if (!quiet) printf("No packages installed.\n"); return (EX_UNAVAILABLE); } if (ret != EPKG_OK) return (EX_IOERR); i = 0; do { gotone = false; pkgname = argv[i]; if (match != MATCH_ALL && pkgname[0] == '\0') { fprintf(stderr, "Pattern must not be empty.\n"); i++; continue; } /* * allow to search for origin with a trailing / * likes audio/linux-vsound depending on ${PORTSDIR}/audio/sox/ */ if (argc > 0 && pkgname[strlen(pkgname) -1] == '/') pkgname[strlen(pkgname) -1] = '\0'; if (argc > 0) { j=0; while (pkgname[j] != '\0') { if (pkgname[j] == '<') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = LT; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=LE; j++; } } else { pkgversion = pkgname + j; sign = LT; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=LE; j++; } } } else if (pkgname[j] == '>') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = GT; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=GE; j++; } } else { pkgversion = pkgname + j; sign = GT; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=GE; j++; } } } else if (pkgname[j] == '=') { if (pkgversion) { pkgversion2 = pkgname + j; sign2 = EQ; pkgversion2[0] = '\0'; pkgversion2++; if (pkgversion2[0] == '=') { pkgversion2++; sign=EQ; j++; } } else { pkgversion = pkgname + j; sign = EQ; pkgversion[0] = '\0'; pkgversion++; if (pkgversion[0] == '=') { pkgversion++; sign=EQ; j++; } } } j++; } } else pkgversion = NULL; if ((it = pkgdb_query(db, pkgname, match)) == NULL) { return (EX_IOERR); } /* this is place for compatibility hacks */ /* ports infrastructure expects pkg info -q -O to always return 0 even * if the ports doesn't exists */ if (origin_search) gotone = true; /* end of compatibility hacks */ query_flags = info_flags(opt); while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) { gotone = true; const char *version; pkg_get(pkg, PKG_VERSION, &version); if (pkgversion != NULL) { switch (pkg_version_cmp(version, pkgversion)) { case -1: if (sign != LT && sign != LE) { gotone = false; continue; } break; case 0: if (sign != LE && sign != GE && sign != EQ) { gotone = false; continue; } break; case 1: if (sign != GT && sign != GE) { gotone = false; continue; } break; } } if (pkgversion2 != NULL) { switch (pkg_version_cmp(version, pkgversion2)) { case -1: if (sign2 != LT && sign2 != LE) { gotone = false; continue; } break; case 0: if (sign2 != LE && sign2 != GE && sign2 != EQ) { gotone = false; continue; } break; case 1: if (sign2 != GT && sign2 != GE) { gotone = false; continue; } break; } } if (pkg_exists) retcode = EX_OK; else print_info(pkg, opt); } if (ret != EPKG_END) { retcode = EX_IOERR; } if (retcode == EX_OK && !gotone && match != MATCH_ALL) { if (!quiet) warnx("No package(s) matching %s", argv[i]); retcode = EX_SOFTWARE; } pkgdb_it_free(it); i++; } while (i < argc); pkg_free(pkg); pkgdb_close(db); return (retcode); }
static int plooptool_info(int argc, char **argv) { int ret, i; int spec = 0; int device = 0; struct ploop_info info = {}; while ((i = getopt(argc, argv, "sd")) != EOF) { switch (i) { case 's': spec = 1; break; case 'd': device = 1; break; default: usage_info(); return SYSEXIT_PARAM; } } argc -= optind; argv += optind; if (argc != 1 || !is_xml_fname(argv[0])) { usage_info(); return SYSEXIT_PARAM; } if (spec || device) { struct ploop_disk_images_data *di; ret = ploop_open_dd(&di, argv[0]); if (ret) return ret; if (spec) { struct ploop_spec spec = {}; ret = ploop_get_spec(di, &spec); if (ret) goto exit; printf("size:\t\t%llu\nblocksize:\t%d\nfmt_version:\t%d\n", (unsigned long long)spec.size, spec.blocksize, spec.fmt_version); } if (device) { char dev[PATH_MAX] = {}; if (ploop_get_dev(di, dev, sizeof(dev)) == -1) { ret = SYSEXIT_SYS; goto exit; } printf("device:\t\t%s\n", dev); } exit: ploop_close_dd(di); } else { ret = ploop_get_info_by_descr(argv[0], &info); if (ret == 0) print_info(&info); } return ret; }
void read_cli_options(int argc, char **argv, struct kw_conf * (*kw)(const char *), FILE ** fin, FILE ** fout) { int i; if (argc == 1) return; // use stdin and stdout if (argc == 2 && strcmp(argv[1], "--create-config-file") == 0) { if (create_conf_file(FSQLF_CONFFILE_NAME) != 0) { exit(1); } else { fprintf(stderr, "File '%s' (re)created.\n", FSQLF_CONFFILE_NAME); exit(0); } } for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { if ((*fin) == stdin) { //try to openinig INPUT file (*fin) = fopen(argv[1], "r"); if (!(*fin)) { FAIL_WITH_ERROR(1, "Error opening input file: %s", argv[i]); } } else if ((*fout) == stdout) { //try to openinig OUTPUT file (only if INPUT file is set) (*fout) = fopen(argv[2], "w+"); if (!(*fout)) FAIL_WITH_ERROR(1, "Error opening output file: %s", argv[i]); } } else if (ARGV_MATCH(i, "-i")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); (*fin) = fopen(argv[i], "r"); if (!(*fin)) FAIL_WITH_ERROR(1, "Error opening input file: %s", argv[i]); } else if (ARGV_MATCH(i, "-o")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); (*fout) = fopen(argv[i], "w+"); if (!(*fout)) FAIL_WITH_ERROR(1, "Error opening output file: %s", argv[i]); } else if (ARGV_MATCH(i, "--config-file")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (read_conf_file(argv[i], kw) == READ_FAILED) { FAIL_WITH_ERROR(1, "Error reading configuration file: %s", argv[i]); } } else if (ARGV_MATCH(i, "--select-comma-newline")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "after") == 0) { kw("kw_comma")->before.new_line = 0; kw("kw_comma")->after.new_line = 1; } else if (strcmp(argv[i], "before") == 0) { kw("kw_comma")->before.new_line = 1; kw("kw_comma")->after.new_line = 0; } else if (strcmp(argv[i], "none") == 0) { kw("kw_comma")->before.new_line = 0; kw("kw_comma")->after.new_line = 0; } } else if (ARGV_MATCH(i, "--keyword-case")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "none") == 0) { set_case(CASE_none); } else if (strcmp(argv[i], "upper") == 0) { set_case(CASE_UPPER); } else if (strcmp(argv[i], "lower") == 0) { set_case(CASE_lower); } else if (strcmp(argv[i], "initcap") == 0) { set_case(CASE_Initcap); } } else if (ARGV_MATCH(i, "--keyword-text")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "original") == 0) { set_text_original(1); } else if (strcmp(argv[i], "default") == 0) { set_text_original(0); } } else if (ARGV_MATCH(i, "--select-newline-after")) { kw("kw_select")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-or-before")) { kw("kw_or")->before.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-or-after")) { kw("kw_or")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-and-before")) { kw("kw_and")->before.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-and-after")) { kw("kw_and")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-major-sections")) { int new_line_count = get_int_arg(++i, argc, argv); kw("kw_from")->before.new_line = new_line_count; kw("kw_where")->before.new_line = new_line_count; kw("kw_inner_join")->before.new_line = new_line_count; kw("kw_left_join")->before.new_line = new_line_count; kw("kw_right_join")->before.new_line = new_line_count; kw("kw_full_join")->before.new_line = new_line_count; kw("kw_cross_join")->before.new_line = new_line_count; } else if (ARGV_MATCH(i, "--debug")) { if (++i >= argc ) FAIL_WITH_ERROR(1, "Missing or invalid value for option : %s", argv[i-1]); if (ARGV_MATCH(i, "none")) debug_level |= DEBUGNONE; else if (ARGV_MATCH(i, "state")) debug_level |= DEBUGSTATES; else if (ARGV_MATCH(i, "match")) debug_level |= DEBUGMATCHES; else if (ARGV_MATCH(i, "parenthesis")) debug_level |= DEBUGPARCOUNTS; else FAIL_WITH_ERROR(1, "Missing or invalid value for option : %s", argv[i-1]); } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { usage_info(argc, argv); exit(0); } else FAIL_WITH_ERROR(1, "Option `%s' is not recognised or used incorrectly.\nTry `%s --help' for more information\n", argv[i], argv[0]); } }
int main(int argc, char *argv[]){ int i,j,k; int _vector_size = VECTOR_SIZE; int _iteration = ITERATION; double _initval = INITVAL; int _nodes = NODES; int _column = VECTOR_SIZE+1; int _computer_row = COMPUTER_ROW; int ans_index=0; int change=1; d2mce_mutex_t lock; int task_id; int *initialized; int *schedule_index; int local_index; double computing; double *matrix; double *ans; double *_ans[2]; double time; // processing argument if(argc > 1){ for( i = 1 ; i < argc ;){ if( !strcmp(argv[i], "-s" )){ if(argv[i+1] == NULL){ usage_info(); return 0; } _vector_size = atoi(argv[i+1]); _column = _vector_size + 1; i+=2; } else if( !strcmp(argv[i], "-i")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _iteration = atoi(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-v")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _initval = atof(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-n")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _nodes = atoi(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-r")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _computer_row = atoi(argv[i+1]); i+=2; } else{ usage_info(); return 0; } } } srand( RANDOM_SEED ); d2mce_init(); task_id = d2mce_join("jacobi","abc", 0); d2mce_mutex_init(&lock, "lock"); // init value initialized = (int*)d2mce_malloc("initialized", sizeof(int), 1, 0); schedule_index = (int*)d2mce_malloc("schedule_index", sizeof(int), 1, 0); matrix = (double*) d2mce_malloc("matrix", sizeof(double), _vector_size * _column, 0 ); ans = (double*) d2mce_malloc("ans", sizeof(double), _vector_size, 0 ); //the old ans; // ans[1] = (double*) d2mce_malloc("ans[1]", sizeof(double), _vector_size ); _ans[0] = (double*) malloc(sizeof(double) * _vector_size ); //the new ans; _ans[1] = (double*) malloc(sizeof(double) * _vector_size ); //local index to check the data is dirty if(task_id == 0){ d2mce_mutex_rw(&lock, 4, initialized, "rw", schedule_index, "rw", matrix, "rw", ans, "rw"); for( i=0; i < _vector_size; i++){ ans[i] = (double)_initval; _ans[0][i] = 0; _ans[1][i] = 0; for( j=0; j< _column ; j++){ if(i == j) matrix[i*_column + j] = 0; else matrix[i*_column + j] = create_init_value(); } } *schedule_index = 0; *initialized = 0; d2mce_mutex_unlock(&lock); } else{ while (! initialized) { d2mce_mutex_rw(&lock, 1,initialized,"r"); d2mce_mutex_unlock(&lock); } d2mce_mutex_rw(&lock, 2, matrix, "r", ans, "r" ); d2mce_mutex_unlock(&lock); } if(_nodes >1) d2mce_barrier("wait all init", _nodes); /* for( i=0; i < _vector_size; i++){ for( j=0; j< _column ; j++){ printf("%f ", matrix[i*_column + j]); } printf("\n"); } */ /* ans[0][0]=-1.5; ans[0][1]=2.5; ans[0][2]=-0.5; matrix[0]=-0; matrix[1]=-0.125; matrix[2]=0.25; matrix[3]=-(double)11/8; matrix[_column]=-(double)2/9; matrix[_column+1]=0; matrix[_column+2]=-(double)1/9; matrix[_column+3]=(double)22/9; matrix[2*_column]=(double)1/11; matrix[2*_column+1]=(double)2/11; matrix[2*_column+2]=0; matrix[2*_column+3]=-(double)15/11; */ /* * jacobi method computing */ time = -d2mce_mtime(); for( i=0; i<_iteration; i++){ if(i > 0){ for(j=0; j<_vector_size; j++) _ans[1][j] =0; } while(1){ computing =0; d2mce_mutex_rw(&lock, 1, schedule_index, "rw"); local_index = *schedule_index; *schedule_index += _computer_row; d2mce_mutex_unlock(&lock); if(local_index >=_vector_size) break; for( k=0; k<_vector_size; k++){ if(local_index!=k) computing += matrix[local_index*_column + k]*ans[k]; } computing += matrix[local_index*_column + _vector_size]; _ans[0][local_index] = computing; _ans[1][local_index] = 1; } if(task_id == 0){ d2mce_mutex_rw(&lock, 2, ans, "rw", schedule_index,"rw"); for(j =0 ; j<_vector_size;j++){ if(_ans[1][j] == 1) ans[j] =_ans[0][j]; } *schedule_index=0; d2mce_mutex_unlock(&lock); } else{ d2mce_mutex_rw(&lock, 1, ans, "rw"); for(j =0 ; j<_vector_size;j++){ if(_ans[1][j] == 1) ans[j] =_ans[0][j]; } d2mce_mutex_unlock(&lock); } d2mce_barrier("wait all write back to the ans", _nodes); d2mce_mutex_rw(&lock, 1, ans, "r"); d2mce_mutex_unlock(&lock); } time += d2mce_mtime(); /* * print the result information */ printf("the ans:\n"); for( i=0; i < _vector_size; i++){ printf("%f ", ans[i]); } printf("\n"); printf("execute time:%f\n", time); d2mce_exit(); return 0; }
void read_cli_options(struct fsqlf_kw_conf *kwall, int argc, char **argv, FILE **fin, FILE **fout) { int i; if (argc == 1) return; // use stdin and stdout if (argc == 2 && strcmp(argv[1], "--create-config-file") == 0) { FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[1]); } if (argc == 3 && strcmp(argv[1], "--create-config-file") == 0) { if (fsqlf_kwmap_conffile_create(argv[2]) != FSQLF_OK) { fprintf(stderr, "Problem occurred during creation of config file '%s'.\n", argv[2]); exit(1); } else { fprintf(stderr, "Configuration was written to file '%s'.\n", argv[2]); exit(0); } } for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { if ((*fin) == stdin) { //try to openinig INPUT file (*fin) = fopen(argv[1], "r"); if (!(*fin)) { FAIL_WITH_ERROR(1, "Error opening input file: %s", argv[i]); } } else if ((*fout) == stdout) { //try to openinig OUTPUT file (only if INPUT file is set) (*fout) = fopen(argv[2], "w+"); if (!(*fout)) FAIL_WITH_ERROR(1, "Error opening output file: %s", argv[i]); } } else if (ARGV_MATCH(i, "-i")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); (*fin) = fopen(argv[i], "r"); if (!(*fin)) FAIL_WITH_ERROR(1, "Error opening input file: %s", argv[i]); } else if (ARGV_MATCH(i, "-o")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); (*fout) = fopen(argv[i], "w+"); if (!(*fout)) FAIL_WITH_ERROR(1, "Error opening output file: %s", argv[i]); } else if (ARGV_MATCH(i, "--config-file")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (fsqlf_kwmap_conffile_read(kwall, argv[i]) == FSQLF_FAIL) { FAIL_WITH_ERROR(1, "Error reading configuration file: %s", argv[i]); } } else if (ARGV_MATCH(i, "--select-comma-newline")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "after") == 0) { fsqlf_kw_get(kwall, "kw_comma")->before.new_line = 0; fsqlf_kw_get(kwall, "kw_comma")->after.new_line = 1; } else if (strcmp(argv[i], "before") == 0) { fsqlf_kw_get(kwall, "kw_comma")->before.new_line = 1; fsqlf_kw_get(kwall, "kw_comma")->after.new_line = 0; } else if (strcmp(argv[i], "none") == 0) { fsqlf_kw_get(kwall, "kw_comma")->before.new_line = 0; fsqlf_kw_get(kwall, "kw_comma")->after.new_line = 0; } } else if (ARGV_MATCH(i, "--keyword-case")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "none") == 0) { fsqlf_kwmap_set_case(kwall, FSQLF_KWCASE_ORIGINAL); } else if (strcmp(argv[i], "upper") == 0) { fsqlf_kwmap_set_case(kwall, FSQLF_KWCASE_UPPER); } else if (strcmp(argv[i], "lower") == 0) { fsqlf_kwmap_set_case(kwall, FSQLF_KWCASE_LOWER); } else if (strcmp(argv[i], "initcap") == 0) { fsqlf_kwmap_set_case(kwall, FSQLF_KWCASE_INITCAP); } } else if (ARGV_MATCH(i, "--keyword-text")) { if (++i >= argc) FAIL_WITH_ERROR(1, "Missing value for option : %s", argv[i-1]); if (strcmp(argv[i], "original") == 0) { fsqlf_kwmap_set_spelling(kwall, FSQLF_KWSPELLING_USE_ORIGINAL); } else if (strcmp(argv[i], "default") == 0) { fsqlf_kwmap_set_spelling(kwall, FSQLF_KWSPELLING_USE_HARDCODED_DEFAULT); } } else if (ARGV_MATCH(i, "--select-newline-after")) { fsqlf_kw_get(kwall, "kw_select")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-or-before")) { fsqlf_kw_get(kwall, "kw_or")->before.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-or-after")) { fsqlf_kw_get(kwall, "kw_or")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-and-before")) { fsqlf_kw_get(kwall, "kw_and")->before.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-and-after")) { fsqlf_kw_get(kwall, "kw_and")->after.new_line = get_int_arg(++i, argc, argv); } else if (ARGV_MATCH(i, "--newline-major-sections")) { int new_line_count = get_int_arg(++i, argc, argv); fsqlf_kwmap_set_major_clause_nl(kwall, new_line_count); } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { usage_info(argc, argv); exit(0); } else FAIL_WITH_ERROR(1, "Option `%s' is not recognised or used incorrectly.\nTry `%s --help' for more information\n", argv[i], argv[0]); } }
int main(int argc, char *argv[]){ int i,j,k; int _vector_size = VECTOR_SIZE; int _iteration = ITERATION; double _initval = INITVAL; int _nodes = NODES; int _column = VECTOR_SIZE+1; int ans_index=0; int change=1; d2mce_mutex_t lock; d2mce_barrier_t b1; int node_id; int *initialized; // int local_index; double computing; double *matrix; double *ans; double *_ans[2]; double time; int comp_size = 0; FILE *file; // processing argument if(argc > 1){ for( i = 1 ; i < argc ;){ if( !strcmp(argv[i], "-s" )){ if(argv[i+1] == NULL){ usage_info(); return 0; } _vector_size = atoi(argv[i+1]); _column = _vector_size + 1; i+=2; } else if( !strcmp(argv[i], "-i")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _iteration = atoi(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-v")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _initval = atof(argv[i+1]); i+=2; } else if( !strcmp(argv[i], "-n")){ if(argv[i+1] == NULL){ usage_info(); return 0; } _nodes = atoi(argv[i+1]); i+=2; } else{ usage_info(); return 0; } } } comp_size = _vector_size /_nodes; if(_vector_size%_nodes !=0) comp_size++; srand( RANDOM_SEED ); d2mce_init(); node_id = d2mce_join("jacobi", "eps308", 0); printf("my id%d\n", node_id); d2mce_mutex_init(&lock, "lock"); d2mce_barrier_init(&b1, "b1"); // init value initialized = (int*)d2mce_malloc("initialized", sizeof(int)); matrix = (double*) d2mce_malloc("matrix", sizeof(double)* _vector_size * _column ); ans = (double*) d2mce_malloc("ans", sizeof(double)* _vector_size ); //the old ans; // ans[1] = (double*) d2mce_malloc("ans[1]", sizeof(double), _vector_size ); _ans[0] = (double*) malloc(sizeof(double) * _vector_size ); //the new ans; _ans[1] = (double*) malloc(sizeof(double) * _vector_size ); //local index to check the data is dirty if(node_id == 0){ d2mce_mutex_rw(&lock, 3, initialized, "rw", matrix, "rw", ans, "rw"); for( i=0; i < _vector_size; i++){ ans[i] = (double)_initval; _ans[0][i] = (double)_initval; _ans[1][i] = 0.0; for( j=0; j< _column ; j++){ if(i == j) matrix[i*_column + j] = 0; else matrix[i*_column + j] = create_init_value(); } } *initialized = 0; d2mce_mutex_unlock(&lock); } else{ while (! initialized) { d2mce_mutex_rw(&lock, 1,initialized,"r"); d2mce_mutex_unlock(&lock); } d2mce_mutex_rw(&lock, 2, matrix, "r", ans, "r" ); d2mce_mutex_unlock(&lock); for( i=0; i < _vector_size; i++){ _ans[0][i] = ans[i]; _ans[1][i] = 0.0; } } if(_nodes >1) d2mce_barrier(&b1, _nodes); /* for( i=0; i < _vector_size; i++){ for( j=0; j< _column ; j++){ printf("%f ", matrix[i*_column + j]); } printf("\n"); } printf("\n\n"); for( j=0; j< _column ; j++){ printf("%f ", ans[j]); } printf("\n\n"); for( j=0; j< _column ; j++){ printf("%f ", _ans[0][j]); } printf("\n\n"); for( j=0; j< _column ; j++){ printf("%f ", _ans[1][j]); } printf("\n\n"); */ /* ans[0][0]=-1.5; ans[0][1]=2.5; ans[0][2]=-0.5; matrix[0]=-0; matrix[1]=-0.125; matrix[2]=0.25; matrix[3]=-(double)11/8; matrix[_column]=-(double)2/9; matrix[_column+1]=0; matrix[_column+2]=-(double)1/9; matrix[_column+3]=(double)22/9; matrix[2*_column]=(double)1/11; matrix[2*_column+1]=(double)2/11; matrix[2*_column+2]=0; matrix[2*_column+3]=-(double)15/11; */ /* * jacobi method computing */ time = -d2mce_time(); for( i=0; i<_iteration; i++){ for( j=node_id*comp_size; j<(node_id*comp_size+comp_size) && j<_vector_size; j++){ computing =0; for( k=0; k<_vector_size; k++){ if(j!=k) computing += matrix[j*_column + k]*_ans[ans_index][k]; } computing += matrix[j*_column + _vector_size]; _ans[ans_index + change][j] = computing; } ans_index += change; change = -change; // d2mce_barrier(&b1, _nodes); d2mce_mutex_rw(&lock, 1, ans, "rw"); for( j=node_id*comp_size; j<(node_id*comp_size+comp_size) && j<_vector_size; j++){ ans[j] = _ans[ans_index][j]; } d2mce_mutex_unlock(&lock); d2mce_barrier(&b1, _nodes); d2mce_load(ans); if( i != _iteration){ #ifdef OPENMP #pragma omp parallel for #endif for( j=0; j<_vector_size; j++){ _ans[ans_index][j] = ans[j]; } } } time += d2mce_time(); /* * print the result information */ /* printf("the ans:\n"); for( i=0; i < _vector_size; i++){ printf("%f ", ans[i]); } printf("\n"); */ printf("Result:\n"); printf("\tTIME\tVector_Size\n"); printf("\t%f\t%d\n", time, _vector_size); file = fopen("d2mce_output.data","w"); fwrite(ans, sizeof(double), _vector_size, file); fclose(file); print_overhead(); d2mce_finalize(); free(_ans[0]); free(_ans[1]); return 0; }