double saxpy(size_t N, size_t iterations = 1) { boost::numeric::ublas::compressed_matrix<double> a(N, N), b(N, N); double c = 3; sminit(a.size1(), a); sminit(b.size1(), b); std::vector<double> times; for(size_t i = 0; i < iterations; ++i){ auto start = std::chrono::steady_clock::now(); a += b * c; auto end = std::chrono::steady_clock::now(); auto diff = end - start; times.push_back(std::chrono::duration<double, std::milli> (diff).count()); //save time in ms for each iteration } double tmin = *(std::min_element(times.begin(), times.end())); double tavg = average_time(times); /* // check to see if nothing happened during rum to invalidate the times if(tmin*(1.0 + deviation*0.01) < tavg){ std::cerr << "uBLAS kernel 'saxpy': Time deviation too large!!!" << std::endl; } */ return tavg; }
double smatsmatmult(size_t N, size_t iterations = 1) { mtl::compressed2D<value_type> a(N, N), b(N, N), c(N, N); sminit(N, a); sminit(N, b); std::vector<double> times; for(size_t i = 0; i < iterations; ++i){ auto start = std::chrono::steady_clock::now(); c = a * b; auto end = std::chrono::steady_clock::now(); auto diff = end - start; times.push_back(std::chrono::duration<double, std::milli> (diff).count()); //save time in ms for each iteration } double tmin = *(std::min_element(times.begin(), times.end())); double tavg = average_time(times); // check to see if nothing happened during run to invalidate the times if(variance(tavg, times) > max_variance){ std::cerr << "mtl kernel 'smatsmatmult': Time deviation too large! \n"; } return tavg; }
static void xms_helper_init(void) { int i; if (!config.ext_mem) return; LWORD(eax) = 0; /* report success */ if (config.xms_size) return; config.xms_size = EXTMEM_SIZE >> 10; x_printf("XMS: initializing XMS... %d handles\n", NUM_HANDLES); freeHMA = 1; a20_global = a20_local = 0; handle_count = 0; for (i = 0; i < NUM_HANDLES + 1; i++) { if (handles[i].valid && handles[i].addr) xms_free(handles[i].addr); handles[i].valid = 0; } smdestroy(&mp); sminit(&mp, ext_mem_base, config.xms_size * 1024); smregister_error_notifier(&mp, xx_printf); }
double smatsvecmult(size_t N, size_t iterations = 1) { boost::numeric::ublas::compressed_matrix<value_type> a(N, N); boost::numeric::ublas::compressed_vector<value_type> b(N), c(N); sminit(a.size1(), a); svinit(b.size(), b); std::vector<double> times; for(size_t i = 0; i < iterations; ++i){ auto start = std::chrono::steady_clock::now(); noalias(c) = prod(a, b); auto end = std::chrono::steady_clock::now(); auto diff = end - start; times.push_back(std::chrono::duration<double, std::milli> (diff).count()); //save time in ms for each iteration } double tmin = *(std::min_element(times.begin(), times.end())); double tavg = average_time(times); // check to see if nothing happened during run to invalidate the times if(variance(tavg, times) > max_variance){ std::cerr << "boost kernel 'smatsvecmult': Time deviation too large! \n"; } return tavg; }
int sminit_com(struct mempool *mp, void *start, size_t size, int (*commit)(void *area, size_t size), int (*uncommit)(void *area, size_t size)) { sminit(mp, start, size); mp->commit = commit; mp->uncommit = uncommit; return 0; }
static int open_mapping_f(int cap) { int mapsize, estsize, padsize; if (cap) Q_printf("MAPPING: open, cap=%s\n", decode_mapping_cap(cap)); padsize = 4*1024; /* first estimate the needed size of the mapfile */ mapsize = HMASIZE >> 10; /* HMA */ /* VGAEMU */ mapsize += config.vgaemu_memsize ? config.vgaemu_memsize : 1024; mapsize += config.ems_size; /* EMS */ mapsize += LOWMEM_SIZE >> 10; /* Low Mem */ estsize = mapsize; /* keep heap fragmentation in mind */ mapsize += (mapsize/4 < padsize ? padsize : mapsize/4); mpool_numpages = mapsize / 4; mapsize = mpool_numpages * PAGE_SIZE; /* make sure we are page aligned */ ftruncate(tmpfile_fd, 0); if (ftruncate(tmpfile_fd, mapsize) == -1) { if (!cap) error("MAPPING: cannot size temp file pool, %s\n",strerror(errno)); discardtempfile(); if (!cap)return 0; leavedos(2); } /* /dev/shm may be mounted noexec, and then mounting PROT_EXEC fails. However mprotect may work around this (maybe not in future kernels) */ mpool = mmap(0, mapsize, PROT_READ|PROT_WRITE, MAP_SHARED, tmpfile_fd, 0); if (mpool == MAP_FAILED || mprotect(mpool, mapsize, PROT_READ|PROT_WRITE|PROT_EXEC) == -1) { char *err = strerror(errno); char s[] = "MAPPING: cannot size temp file pool, %s\n"; discardtempfile(); if (!cap) { Q_printf(s,err); return 0; } leavedos(2); } /* the memory pool itself can just be rw though */ mprotect(mpool, mapsize, PROT_READ|PROT_WRITE); Q_printf("MAPPING: open, mpool (min %dK) is %d Kbytes at %p-%p\n", estsize, mapsize/1024, mpool, mpool+mapsize-1); sminit(&pgmpool, mpool, mapsize); /* * Now handle individual cases. * Don't forget that each of the below code pieces should only * be executed once ! */ #if 0 if (cap & MAPPING_OTHER) { /* none for now */ } #endif #if 0 if (cap & MAPPING_EMS) { /* none for now */ } #endif #if 0 if (cap & MAPPING_DPMI) { /* none for now */ } #endif #if 0 if (cap & MAPPING_VIDEO) { /* none for now */ } #endif #if 0 if (cap & MAPPING_VGAEMU) { /* none for now */ } #endif #if 0 if (cap & MAPPING_HGC) { /* none for now */ } #endif #if 0 if (cap & MAPPING_HMA) { /* none for now */ } #endif #if 0 if (cap & MAPPING_SHARED) { /* none for now */ } #endif #if 0 if (cap & MAPPING_INIT_HWRAM) { /* none for now */ } #endif #if 0 if (cap & MAPPING_INIT_LOWRAM) { /* none for now */ } #endif return 1; }
int commands_plugin_inte6(void) { #define MAX_ARGS 63 char *args[MAX_ARGS + 1]; struct PSP *psp; struct MCB *mcb; struct com_program_entry *com; int argc; if (pool_used >= MAX_NESTING) { com_error("Cannot invoke more than %i builtins\n", MAX_NESTING); return 0; } if (!pool_used) { if (!(lowmem_pool = lowmem_heap_alloc(LOWMEM_POOL_SIZE))) { error("Unable to allocate memory pool\n"); return 0; } sminit(&mp, lowmem_pool, LOWMEM_POOL_SIZE); } pool_used++; BMEM(allocated) = 0; BMEM(retcode) = 0; if (HI(ax) != BUILTINS_PLUGIN_VERSION) { com_error("builtins plugin version mismatch: found %i, required %i\n", HI(ax), BUILTINS_PLUGIN_VERSION); com_error("You should update your generic.com, ems.sys, isemu.com and other utilities\n" "from the latest dosemu package!\n"); commands_plugin_inte6_done(); return 0; } psp = COM_PSP_ADDR; mcb = LOWMEM(SEGOFF2LINEAR(COM_PSP_SEG - 1,0)); /* first parse commandline */ args[0] = strdup(com_getarg0()); strupperDOS(args[0]); argc = com_argparse((char *)&psp->cmdline_len, &args[1], MAX_ARGS - 1) + 1; /* DOS 4 and up */ strncpy(builtin_name, mcb->name, sizeof(builtin_name) - 1); builtin_name[sizeof(builtin_name) - 1] = 0; strupperDOS(builtin_name); com = find_com_program(builtin_name); /* DOS 3.0->3.31 construct the program name from the environment */ if(!com) { char *p = strrchr(args[0],'\\'); strncpy(builtin_name, p+1, sizeof(builtin_name) - 1); builtin_name[sizeof(builtin_name) - 1] = 0; p = strchr(builtin_name, '.'); if(p) *p = '\0'; com = find_com_program(builtin_name); } if (com) { int err = com->program(argc, args); if (!err) { NOCARRY; } else { CARRY; _AL = err; } } else { com_error("inte6: unknown builtin: %s\n",builtin_name); CARRY; _AL = 1; } free(args[0]); return 1; }