static void provide(char *conf_name, char *mvm_id_str) { struct CONF *conf; unsigned long sz; int fd, mvm_id; void *mem; char x; conf = config_parse(conf_name); sz = config_get_int(conf, "size"); sz *= 1024 * 1024; assert(sz); mvm_id = atoi(mvm_id_str); assert(mvm_id); mem = valloc(sz); assert(mem); fd = init_mvm(sz, mem, conf, mvm_id); printf("Providing, press [enter] to finish.\n"); fscanf(stdin, "%c", &x); heca_close(fd); config_clean(conf); free(mem); }
static void provide(char *conf_name, int mvm_id, char c) { struct CONF *conf; unsigned long sz = PAGE_SIZE*NUM_PAGES*mr_count; int fd, i; void *mem; conf = config_parse(conf_name); assert(conf); mem = valloc(sz); assert(mem); memset(mem, c, sz); for_each_mr (i) mr_array[i].addr = mem + (i * mr_array[i].sz); printf("[0] initialize %d: ", mvm_id); notify(""); fd = init_mvm(sz, mem, conf, mvm_id); if (fd < 0) { fprintf(stderr, "can't open /dev/heca\n"); return; } notify("[3] dirty pages:"); c = (mvm_id % 2)? 'd' : 'e'; dirty_pages(NUM_PUSHBACK, c); notify("[6] dirty and print pages (2):"); dirty_pages(NUM_PUSHBACK, '2'); print_pages(NUM_PUSHBACK); notify("[.]disconnect:\n"); heca_close(fd); }
static void compute(int svm_id, char *conf_name) { struct CONF *conf = NULL; int fd, i, num; void *mem, *svm_mem; unsigned long sz, svm_sz; char x; assert(conf_name); conf = config_parse(conf_name); assert(conf); num = config_count_ints(conf); assert(num); sz = config_get_int(conf, "size"); assert(sz); sz *= 1024 * 1024; /* allocate mem and init */ mem = valloc(sz); assert(mem); svm_sz = sz/num; svm_mem = mem + (svm_id-1)*(svm_sz); for (i = 0; i < svm_sz/sizeof(int); i++) *((int *) (svm_mem + i*sizeof(int))) = svm_id; /* initialize */ if (svm_id == 1) { struct hecaioc_mr mr_array[num]; for (i = 0; i < num; i++) { mr_array[i].mr_id = i+1; mr_array[i].dsm_id = 1; mr_array[i].svm_ids[0] = i+1; mr_array[i].svm_ids[1] = 0; mr_array[i].sz = svm_sz; mr_array[i].addr = mem + svm_sz*i; mr_array[i].flags = UD_AUTO_UNMAP | UD_SHARED; } fd = init_cvm(0, conf, mr_array, num, 0); } else { fd = init_mvm(sz, mem, conf, svm_id); } /* payload */ imdb(mem, sz, num); printf("Benchmark finished.\n"); fscanf(stdin, "%c", &x); /* cleanup */ heca_close(fd); config_clean(conf); free(mem); }
void init_globals() { init_mvm(); }