int main(int ac, char **av) { int len; int range; int stride; int i; char *addr; len = atoi(av[1]) * 1024 * 1024; addr = (char *)malloc(len); if (av[2] == 0) { fprintf(stderr, "\"stride=%d\n", STRIDE); for (range = LOWER; range <= len; range = step(range)) { loads(addr, range, STRIDE); } } else { for (i = 2; i < ac; ++i) { stride = bytes(av[i]); fprintf(stderr, "\"stride=%d\n", stride); for (range = LOWER; range <= len; range = step(range)) { loads(addr, range, stride); } fprintf(stderr, "\n"); } } return(0); }
int main(int ac, char **av) { int i; int c; int parallel = 1; int warmup = 0; int repetitions = TRIES; size_t len; size_t range; size_t stride; char *usage = "[-P <parallelism>] [-W <warmup>] [-N <repetitions>] [-t] len [stride...]\n"; while (( c = getopt(ac, av, "tP:W:N:")) != EOF) { switch(c) { case 't': fpInit = thrash_initialize; break; case 'P': parallel = atoi(optarg); if (parallel <= 0) lmbench_usage(ac, av, usage); break; case 'W': warmup = atoi(optarg); break; case 'N': repetitions = atoi(optarg); break; default: lmbench_usage(ac, av, usage); break; } } if (optind == ac) { lmbench_usage(ac, av, usage); } len = atoi(av[optind]); len *= 1024 * 1024; if (optind == ac - 1) { fprintf(stderr, "\"stride=%d\n", (int)STRIDE); for (range = LOWER; range <= len; range = step(range)) { loads(len, range, STRIDE, parallel, warmup, repetitions); } } else { for (i = optind + 1; i < ac; ++i) { stride = bytes(av[i]); fprintf(stderr, "\"stride=%d\n", (int)stride); for (range = LOWER; range <= len; range = step(range)) { loads(len, range, stride, parallel, warmup, repetitions); } fprintf(stderr, "\n"); } } return(0); }
int main(int ac, char **av) { int maxlen = 64 * 1024 * 1024; int warmup = 0; int repetitions = -1; int c; struct dram_page_state state; double dram_hit, dram_miss; char *usage = "[-v] [-W <warmup>] [-N <repetitions>][-M len[K|M]]\n"; state.mstate.width = 1; state.mstate.line = sizeof(char*); state.mstate.pagesize = getpagesize(); state.group = 16; while (( c = getopt(ac, av, "aL:T:M:W:N:")) != EOF) { switch(c) { case 'L': state.mstate.line = bytes(optarg); break; case 'T': state.group = bytes(optarg); break; case 'M': maxlen = bytes(optarg); break; case 'W': warmup = atoi(optarg); break; case 'N': repetitions = atoi(optarg); break; default: lmbench_usage(ac, av, usage); break; } } dram_hit = loads(mem_initialize, maxlen, warmup, repetitions, &state); dram_miss = loads(dram_page_initialize, maxlen, warmup, repetitions, &state); if (dram_hit < 0.95 * dram_miss) { fprintf(stderr, "%f\n", dram_miss - dram_hit); } else { fprintf(stderr, "0.0\n"); } return (0); }
/** * Parse message to return a request and handler id */ Request Proto::build_request(std::string msg) { PError err; JValue* req_json = loads(msg, err); // check json integrity if (req_json == nullptr || !req_json->isObject()) { throw ServerJsonNotParsedException(); } // check clientno JValue* item_json = req_json->get(ClientNo); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } int clientno = item_json->getInteger(); // check serverno item_json = req_json->get(ServerNo); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } int serverno = item_json->getInteger(); // check version item_json = req_json->get(Version); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } int version = item_json->getInteger(); // check timestamp item_json = req_json->get(Timestamp); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } long timestamp = item_json->getInteger(); // check messageid item_json = req_json->get(MessageId); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } int messageid = item_json->getInteger(); // check handler id item_json = req_json->get(Method); if (item_json == nullptr || !item_json->isInteger()) { throw ServerJsonNotParsedException(); } size_t handlerid = item_json->getInteger(); // check parameters item_json = req_json->get(Param); if (item_json == nullptr || !item_json->isArray()) { throw ServerJsonNotParsedException(); } Request request(clientno, serverno, version, timestamp, messageid, handlerid, item_json, req_json); return request; }
//自动切分纹理产生纹理数组的方法 static void generateTexCoor(){ int bw = (int)(360/angleSpan); int bh = (int)(180/angleSpan); float *result= pTexture; float sizew=1.0f/bw;//列数 float sizeh=1.0f/bh;//行数 int c=0; int i,j; for(i=0;i<bh;i++){ for(j=0;j<bw;j++){ //每行列一个矩形,由两个三角形构成,共六个点,12个纹理坐标 float s=j*sizew; float t=i*sizeh; #define loads(x) (result[c++]= 1.0 - (x)) #define loadt(x) (result[c++]= (x)) loads(s); loadt(t); loads(s); loadt(t+sizeh); loads(s+sizew); loadt(t); loads(s+sizew); loadt(t); loads(s); loadt(t+sizeh); loads(s+sizew); loadt(t+sizeh); } } }
JValue* Proto::parse_response(std::string response) { PError err; JValue* json_resp = loads(response, err); if (json_resp == nullptr) { LOG(FATAL) << VarString::format("Json parse error, json text[%s], error text[%s]", response.c_str(), err.text.c_str()) << std::endl; } if (! json_resp->isObject() ) { LOG(FATAL) << VarString::format("Json format error, response has to be an object. Json text[%s]", response.c_str()) << std::endl; } if (json_resp->contain(Error) ) { int errcode = json_resp->get(Error)->getInteger(); switch(errcode) { case SOCKET_CLOSED: LOG(DEBUG) << "Server closed socket" << std::endl; delete json_resp; throw ServerCloseSocketException(); case METHOD_NOT_FOUND: LOG(DEBUG) << "Method not found on server" << std::endl; delete json_resp; throw ServerMethodNotFoundException(); case JSON_NOT_PARSED: LOG(DEBUG) << "Server parse json failed" << std::endl; delete json_resp; throw ServerJsonNotParsedException(); case PARAM_MISMATCH: LOG(DEBUG) << "Parameters don't match with the method" << std::endl; delete json_resp; throw ServerParamMismatchException(); break; case BAD_MESSAGE: LOG(DEBUG) << "Message sent out was broken" << std::endl; delete json_resp; throw ServerBadMessageException(); default: LOG(FATAL) << "Unknown error code " << errcode << std::endl; } } return json_resp; }
void LoadElision::apply(RirCompiler&, ClosureVersion* function, LogStream& log) const { AvailableLoads loads(function, log); Visitor::runPostChange(function->entry, [&](BB* bb) { auto ip = bb->begin(); while (ip != bb->end()) { auto next = ip + 1; auto instr = *ip; if (LdVar::Cast(instr) || LdFun::Cast(instr)) { if (auto domld = loads.get(instr)) { instr->replaceUsesWith(domld); next = bb->remove(ip); } } ip = next; } }); }
int main(int ac, char **av) { size_t len; size_t range; size_t size; int i; unsigned long mask = 0; unsigned int masklen = sizeof(mask); char *addr; cpu_set_t core; int num_cpus = 1; if(ac > 1) num_cpus = atoi(av[1]); for(i = 0; i < num_cpus; i++) { CPU_ZERO(&core); CPU_SET(i, &core); if (sched_setaffinity(0, sizeof(core), &core) < 0) { perror("sched_setaffinity"); exit(-1); } len = 128 * 1024 * 1024; addr = (char *)malloc(len); fprintf(stderr, "\"stride=%d\n", STRIDE); for (range = LOWER; range <= len; range = step(range)) { loads(addr, range, STRIDE, i); } free(addr); } return(0); }
void start() { char ch,ch1; loads(); cout<<"\t\t\t\t\t\t\tWELCOME TO MANAGER MODE\n\t\t\t\t\t\t\t_______________________\n\n\n"; createlist(); chooseteam(); createplayerlist(); cout<<"\nPlease enter the manager details\n\n"; t[I].get2(); cout<<"\n\nTEAM AND MANAGER DETAILS\n________________________\n\n"; t[I].disp3(); t[I].disp1(); t[I].disp2(); cout<<"\nAre you ready to begin(y/n):"; cin>>ch; cout<<"\n\n\nPLAYER LIST\n___________\n\n"; if(ch=='y') { displaylist(); chooseplayers(); if(t[I].rem<=0) { cout<<"\n\nOOPS!! You are out of cash\n YOU'RE FIRED FROM THE JOB"; cout<<"\nDo you want to try again (y/n):"; cin>>ch; if(ch=='y') { system("cls"); for(int k=0;k<8;k++) { t[k].rem=60000; t[k].points=0; t[k].w=0; t[k].l=0; t[k].d=0; } main(); } else if(ch=='n') exit(0); else { cout<<"Invalid.Enter again:"; cin>>ch; if(ch=='y') { system("cls"); for(int k=0;k<8;k++) { t[k].rem=60000; t[k].points=0; t[k].w=0; t[k].l=0; t[k].d=0; } main(); } else if(ch=='n') exit(0); } }
boost::python::object loads(const char * py_str, uint32_t size) const { return loads(std::string(py_str, size)); }
JValue* loads(const char* buffer, PError& err) { std::string str_buffer(buffer); return loads(str_buffer, err); }
int main() { char lstr[8][64]; char buffer[80]; char verb[80]; char wd[512]; int len; int prog; int selected_sbuffer = 0; while (1) { iwrites("wsh-"); fgetwd(wd); iwrites(wd); iwrites("> "); ireads(buffer, 80); len = sfindc(buffer, ' '); if (len < 0) len = slength(buffer); scopy(verb, buffer, len); if (!scompare(verb, "help")) { iwrites("\ncat: print file contents\ncd: change directories\necho: print a string\nhelp: display this message\nls: list files\npwd: print current working directory\nloads: load a string to be used with all commands which act upon strings\nprintf: write to a pre-existing file\nprints: print the currently loaded string\nrms: unload the currently loaded string\ncons: concatenate a string to the end of the currently loaded string\nloadfs: load the contents of a file into the String Buffer\nchsf: switch to the next String Buffer\nchsb: switch to the previous String Buffer\npsb: print the currently selected String Buffer\nreboot: reboot the operating system\n\n"); } else if (!scompare(verb, "ls")) { ls(); } else if (!scompare(verb, "cd")) { cd(buffer + len + 1); } else if (!scompare(verb, "cat")) { /* Mrew? */ cat(buffer + len + 1); } else if (!scompare(verb, "echo")){ echo(buffer + len + 1); } else if (!scompare(verb, "pwd")){ pwd(); } else if (!scompare(verb, "reboot")) { ireboot(); } else if (!scompare(verb, "printf")) { printf(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "loads")) { loads(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "prints")) { iwrites(lstr[selected_sbuffer]); iwrites("\n"); } else if (!scompare(verb, "rms")) { scopy(lstr[selected_sbuffer], "\0", 1); } else if (!scompare(verb, "loadfs")) { loadfs(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "cons")) { cons(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "chsf")) { selected_sbuffer = chsf(selected_sbuffer); } else if (!scompare(verb, "psb")) { psb(selected_sbuffer); } else if (!scompare(verb, "chsb")) { selected_sbuffer = chsb(selected_sbuffer); } /* else if (!scompare(verb, "mk")) { mk(buffer + len + 1); } */ else if (sfindc(verb, '/') == -1) { prog = fget("/bin/"); if (!prog) { iwrites("Error: unable to locate bin directory\n"); continue; } prog = ffind(prog, verb); if (!prog) { iwrites("Error: unrecognized command \""); iwrites(verb); iwrites("\"\n"); continue; } if (fgettype(prog) == 2) iexec(prog); else { iwrites("Error: file is not executable\n"); continue; } } else if (prog = fget(verb)) { if (fgettype(prog) == 2) iexec(prog); else { iwrites("Error: file is not executable\n"); continue; } } else { iwrites("Error: executable not found\n"); continue; } } }