static void print_resource_usage(const resource_usage_t *usage_before, const char *title) { resource_usage_t usage_after; get_resource_usage(&usage_after); if ((usage_after.memory != -1) && (usage_before->memory != -1) && (usage_after.num_fds != -1) && (usage_before->num_fds != -1)) { printf("# memory: %.2fMB, file descriptors: %d\n", (usage_after.memory - usage_before->memory) / (1024.0 * 1024.0), (usage_after.num_fds - usage_before->num_fds)); } printf("# create time: %.3f ms\n", ucs_time_to_msec(usage_after.time - usage_before->time)); printf("#\n"); }
void calc_job_weight(Job *job) { int timeQd; float usage, weight, A, B, C, D, E, F; double priority; timeQd = schd_TimeNow - job->eligible; usage = get_resource_usage(job->owner); if (!strcmp(job->oqueue, schd_SpecialQueue)) job->priority = 1000; else if (!strcmp(job->oqueue, schd_ChallengeQueue)) job->priority = 900; else if (!strcmp(job->oqueue, schd_BackgroundQueue)) job->priority = -100; else job->priority = 0; /* these should be set by parameters in the config file */ /* These are used to scale the impact of various attributes */ /* of the job on the job weight, used in the priority calc */ A = 4.0; /* Adjust recent usage */ B = 2.0; /* Adjust job size (nodes) */ C = 1.0 / 7.0; /* Adjust time queued */ /* Use user supplied values for weight of each factor: */ /* For simplicty, the user tunable parameters are in the */ /* range of 1-10, or 0 (no weight). We scale these into */ /* new ranges such that the values proportionately affect */ /* the calculated weight of the job. */ /* */ /* Recommended input values for a large system are: */ /* */ /* schd_USAGE_WEIGHT = 10 */ /* schd_NODES_WEIGHT = 7 */ /* schd_TIMEQ_WEIGHT = 1 */ /* */ A = schd_USAGE_WEIGHT / 2.50000; /* scale to range 1-4 */ B = schd_NODES_WEIGHT / 3.33333; /* scale to range 1-3 */ C = schd_TIMEQ_WEIGHT / 1.42857; /* scale to range 1-7 */ D = 0.001; /* Bring baseline into desired range */ E = 0.3; /* Adjust slope of tanh() curve */ F = 1.0; /* Adjust slope of tanh() curve */ /* scale the priority (set by the originating queue) such */ /* that the tanh() on the baseline produces appropriate */ /* values (eg. with the ranges stated above). */ if (job->priority >= 1000) job->priority *= 10; else if (job->priority >= 900) job->priority *= 7.8; else if (job->priority >= 0) job->priority = 100; else if (job->priority < 0) job->priority *= -1; weight = -A * usage / schd_MAX_NCPUS + B * job->nodes / schd_MAX_NCPUS + C * timeQd / SECS_PER_HOUR + D * job->priority ; priority = 500 * (1 + tanh(E * weight - F)); if (job->priority < 0) job->priority = -1 * (1024 - priority); }
void print_ucp_info(int print_opts, ucs_config_print_flags_t print_flags, uint64_t ctx_features, const ucp_ep_params_t *base_ep_params, size_t estimated_num_eps, unsigned dev_type_bitmap, const char *mem_size) { ucp_config_t *config; ucs_status_t status; ucs_status_ptr_t status_ptr; ucp_context_h context; ucp_worker_h worker; ucp_params_t params; ucp_worker_params_t worker_params; ucp_ep_params_t ep_params; ucp_address_t *address; size_t address_length; resource_usage_t usage; ucp_ep_h ep; status = ucp_config_read(NULL, NULL, &config); if (status != UCS_OK) { return; } memset(¶ms, 0, sizeof(params)); params.field_mask = UCP_PARAM_FIELD_FEATURES | UCP_PARAM_FIELD_ESTIMATED_NUM_EPS; params.features = ctx_features; params.estimated_num_eps = estimated_num_eps; get_resource_usage(&usage); if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_SELF))) { ucp_config_modify(config, "SELF_DEVICES", ""); } if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_SHM))) { ucp_config_modify(config, "SHM_DEVICES", ""); } if (!(dev_type_bitmap & UCS_BIT(UCT_DEVICE_TYPE_NET))) { ucp_config_modify(config, "NET_DEVICES", ""); } status = ucp_init(¶ms, config, &context); if (status != UCS_OK) { printf("<Failed to create UCP context>\n"); goto out_release_config; } if ((print_opts & PRINT_MEM_MAP) && (mem_size != NULL)) { ucp_mem_print_info(mem_size, context, stdout); } if (print_opts & PRINT_UCP_CONTEXT) { ucp_context_print_info(context, stdout); print_resource_usage(&usage, "UCP context"); } if (!(print_opts & (PRINT_UCP_WORKER|PRINT_UCP_EP))) { goto out_cleanup_context; } worker_params.field_mask = UCP_WORKER_PARAM_FIELD_THREAD_MODE; worker_params.thread_mode = UCS_THREAD_MODE_MULTI; get_resource_usage(&usage); status = ucp_worker_create(context, &worker_params, &worker); if (status != UCS_OK) { printf("<Failed to create UCP worker>\n"); goto out_cleanup_context; } if (print_opts & PRINT_UCP_WORKER) { ucp_worker_print_info(worker, stdout); print_resource_usage(&usage, "UCP worker"); } if (print_opts & PRINT_UCP_EP) { status = ucp_worker_get_address(worker, &address, &address_length); if (status != UCS_OK) { printf("<Failed to get UCP worker address>\n"); goto out_destroy_worker; } ep_params = *base_ep_params; ep_params.field_mask |= UCP_EP_PARAM_FIELD_REMOTE_ADDRESS; ep_params.address = address; status = ucp_ep_create(worker, &ep_params, &ep); ucp_worker_release_address(worker, address); if (status != UCS_OK) { printf("<Failed to create UCP endpoint>\n"); goto out_destroy_worker; } ucp_ep_print_info(ep, stdout); status_ptr = ucp_disconnect_nb(ep); if (UCS_PTR_IS_PTR(status_ptr)) { do { ucp_worker_progress(worker); status = ucp_request_test(status_ptr, NULL); } while (status == UCS_INPROGRESS); ucp_request_release(status_ptr); } } out_destroy_worker: ucp_worker_destroy(worker); out_cleanup_context: ucp_cleanup(context); out_release_config: ucp_config_release(config); }
int main(int argc, char *argv[], char *envp[]) { char answer[128], filename[64]; int cache_page, line_offset, value; FILE *logfp; int i, j, k, ret; int *tmparray; /* for malloc'd static array */ struct rlimit rlims; struct rusage r_start, r_stop; cache_page = getpagesize(); /* Ask for line_offset */ again: fprintf(stdout, "\nEnter line_offset: "); fgets(answer, sizeof(answer) - 1, stdin); fflush(stdin); line_offset = atoi(answer); if ( (cache_page < line_offset) || (line_offset < 1) ) { fprintf(stderr, "\nline_offset=%d out of range [1, %d]", line_offset, cache_page); fflush(stderr); goto again; } /* Reduce MAX_RSS to be NICE to other users */ #if defined(__alpha) rlims.rlim_cur = NEW_MAX_RSS; /* soft */ rlims.rlim_max = NEW_MAX_RSS; /* hard */ if(setrlimit(RLIMIT_RSS, &rlims) < 0) { perror("setrlimit: "); exit(-1); } #endif /* Reduce our priority to be NICE to other users PRIO_MAX is 20 on pegasus so we are doing nice(19) */ if (nice(PRIO_MAX - 1) < 0) { perror("nice: "); exit(-1); } /* open log file */ sprintf(filename, "cache_%4.4d.log", line_offset); logfp = fopen(filename, "w"); if (logfp == (FILE *)NULL) { fprintf(stderr, "\n\nmain: *** fopen(\"%s\",\"w\") failed ***\n\n", filename); fflush(stderr); return(-3); } /* get starting baseline resource usage */ ret = get_resource_usage(RUSAGE_SELF, &r_start); if (ret != 0) { fprintf(stderr, "\n..get_resource_usage(RUSAGE_SELF,..) return %d ", ret); fflush(stderr); } /* initialize and start timers */ init_timing(); /* allocate tmparray[] in data segment */ tmparray = (int *)malloc(NUM_ENTRIES * cache_page * sizeof(int)); if (tmparray == (int *)NULL) { fprintf(stderr, "\nmalloc: fatal error:"); fflush(stderr); exit(-4); } fprintf(stdout, "\nUsing line_offset=%d cache_page=%d..", line_offset, cache_page); fflush(stdout); fprintf(logfp, "\nUsing line_offset=%d cache_page=%d..", line_offset, cache_page); fflush(logfp); value = 0; for (k = 0 ; k < REPEAT ; k++) { i = 0; /* only for fprintf() */ j = 0; if ((k % 32) == 0) { fprintf(stdout, "\n..setting entry, tmparry[], value [%9d,%9d,%9d]", i, j, value); fflush(stdout); } for (i = 0 ; i < NUM_ENTRIES ; i++) { tmparray[j] = value; /* tmparray[j] will be kept in the L2 cache until cache contention with newer data forces it to be written out to (slower) main memory */ j = j + line_offset; value++; if ( ((i % 1024) == 0) && ((k % 32) == 0) ) { putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); putchar(0x08); fprintf(stdout, "%9d,%9d,%9d]", i, j, value); fflush(stdout); } } /* end of for (i = .. */ } /* end of for (k = .. */ /* get ending resource usage */ ret = get_resource_usage(RUSAGE_SELF, &r_stop); if (ret != 0) { fprintf(stderr, "\n..get_resource_usage(RUSAGE_SELF,..) return %d ", ret); fflush(stderr); } /* read timers and then stop them */ read_timing(&real_sec, &real_usec, &virt_sec, &virt_usec, &prof_sec, &prof_usec); pause_timing(); /* print out resources used in rusage struct's to both stdout and our logfile */ fprintf(stdout, "\n..stopping timers "); fprintf_rusage(stdout, &r_start, &r_stop); fprintf(logfp, "\n..stopping timers "); fprintf_rusage(logfp, &r_start, &r_stop); /* printout the total times to both stdout and our logfile */ printf_timing(); fprintf(stdout, "\nNet Memory Bandwidth %8.3f Mbytes/sec: ", ((double)(value*sizeof(int))/((double)prof_sec + (double)prof_usec/1000000.0)) /1000000.0 ); fprintf(stdout, "\n\n"); fflush(stdout); fprintf_timing(logfp, real_sec, real_usec, virt_sec, virt_usec, prof_sec, prof_usec); fprintf(logfp, "\nNet Memory Bandwidth %8.3f Mbytes/sec: ", ((double)(value*sizeof(int))/((double)prof_sec + (double)prof_usec/1000000.0)) /1000000.0 ); fprintf(logfp, "\n\n"); fflush(logfp); fclose(logfp); /* close logfile */ return(0); } /* end of main */