void TimeTasks::print_cycle_times(int cycle) { if(!is_output_thread()) return; FILE* file = stdout; // we could report average for all processes //if(!MPIdata::get_rank()) { fflush(file); fprintf(file,"=== times for cycle %d for rank %d === \n", cycle, MPIdata::get_rank()); fprintf(file, TIMING_PREFIX "total comput commun task\n"); for(int e=NONE+1; e<LAST; e++) { fprintf(file, TIMING_PREFIX "%6.3f %6.3f %6.3f %s\n", get_time(e), get_compute(e), communicate[e], get_taskname(e)); } // report total times // // get total time spent on exclusive tasks // double total_task_duration = 0.; for (int i = NONE + 1; i < LAST; i++) { total_task_duration += task_duration[i]; } // get total time spent in exclusive tasks spent communicating // double total_communicate = 0.; for (int i = NONE + 1; i < LAST; i++) { total_communicate += communicate[i]; } const double total_computing_time = total_task_duration - total_communicate; fprintf(file, TIMING_PREFIX "%6.3f %6.3f %6.3f %s\n", total_task_duration, total_computing_time, total_communicate, "[total times]"); fprintf(file, TIMING_PREFIX "time subtask\n"); for(int e=LAST+1; e<NUMBER_OF_TASKS; e++) { // do not show tasks that are not executed double elapsed_time = get_time(e); if(!elapsed_time) continue; assert_eq(stack_depth[e],0); fprintf(file, TIMING_PREFIX "%6.3f %s\n", elapsed_time, get_taskname(e)); } fflush(file); } }
void original_io_request::compute(io_interface *io, join_compute_allocator *compute_alloc, std::vector<io_request> &requests) { assert(this->get_req_type() == io_request::USER_COMPUTE); original_req_byte_array byte_arr(this); get_compute()->run(byte_arr); compute_alloc->set_compute(get_compute()); get_compute()->fetch_requests(io, compute_alloc, requests); compute_alloc->set_compute(NULL); int num_pages = get_num_covered_pages(); for (int i = 0; i < num_pages; i++) { assert(status_arr[i].pg); status_arr[i].pg->dec_ref(); } // If no one else is referencing the user compute, it means the computation // is complete now. if (get_compute()->get_ref() == 0) { compute_allocator *alloc = get_compute()->get_allocator(); alloc->free(get_compute()); } }
int generate_histdb_prepare(genhistdb_handle_type *_handle, char *dirname, char *dbname, unsigned int nr_threads, generate_mode_t mode) { struct genhistdb_struct *handle; Node *head = NULL; Node *compute = NULL; unsigned int compute_len = 0; if(!dirname || !dbname) return -1; handle = (struct genhistdb_struct *)malloc(sizeof(struct genhistdb_struct)); if(!handle) return -1; if(nr_threads == 0) handle->nr_threads = DEFAULT_NTHREADS; else handle->nr_threads = nr_threads; head = GetMusicFiles(dirname); handle->hist_list = NULL; handle->hist_len = 0; if(mode == UPDATE_MODE) { if(read_histdb(&handle->hist_list, &handle->hist_len, dbname)) { compute = head; } else { compute = get_compute(head, handle->hist_list, handle->hist_len); } } else { compute = get_compute(head, handle->hist_list, handle->hist_len); } compute_len = list_len(compute); if(compute_len > 0) handle->hist_list = realloc(handle->hist_list, sizeof(hist_t) * (handle->hist_len + compute_len)); if(!handle->hist_list) { free(handle); goto realloc_failed; } if(compute_len <= handle->nr_threads) handle->nr_threads = 1; handle->threads = (pthread_t *)calloc(handle->nr_threads, sizeof(pthread_t)); if(!handle->threads) goto threads_failed; handle->per_thread_list = (Node **)calloc(handle->nr_threads, sizeof(Node *)); if(!handle->per_thread_list) goto list_creation_failed; handle->completed = 0; handle->updated = 0; handle->to_complete = compute_len; list_split(handle->per_thread_list, handle->nr_threads, compute); strcpy(handle->dbname, dbname); *_handle = handle; return 0; list_creation_failed: free(handle->threads); threads_failed: free(handle->hist_list); realloc_failed: free(handle); return -1; }
bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3, const p4 & v4, const p5 & v5) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2, v3, v4, v5); }
template<class p1, class p2, class p3, class p4> bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3, const p4 & v4) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2, v3, v4); }
template<class p1, class p2> bool is_enabled(const p1 & v1, const p2 &v2) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2); }
// just in case you do write on another thread virtual void write_array() const { scoped_compute lk( get_compute(), compute::on_other_thread ); write_array_impl( this); }
template<class msg_type> void operator()(msg_type& msg) const { scoped_compute lk( get_compute(), compute::writer ); writer_msg::operator()(msg); }
compute_gather(const compute_gather& other) : m_lk( get_compute(), compute::gather), gather_msg(other) {}
compute_gather() : m_lk( get_compute(), compute::gather) {}
void TimeTasks::print_cycle_times() { if(!get_rank()) { fflush(stdout); fprintf(stdout,"=== timing information for cycle=== \n"); fprintf(stdout, TIMING_PREFIX "moms flds pcls Bfld cycl\n"); fprintf(stdout, TIMING_PREFIX "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f (total time)\n", get_time(TimeTasks::MOMENTS), get_time(TimeTasks::FIELDS), get_time(TimeTasks::PARTICLES), get_time(TimeTasks::BFIELD), get_time() ); fprintf(stdout, TIMING_PREFIX "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f (communication)\n", get_communicate(TimeTasks::MOMENTS), get_communicate(TimeTasks::FIELDS), get_communicate(TimeTasks::PARTICLES), get_communicate(TimeTasks::BFIELD), get_communicate() ); fprintf(stdout, TIMING_PREFIX "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f (computation)\n", get_compute(TimeTasks::MOMENTS), get_compute(TimeTasks::FIELDS), get_compute(TimeTasks::PARTICLES), get_compute(TimeTasks::BFIELD), get_compute() ); fprintf(stdout, TIMING_PREFIX "MOMS comm FLDS comm PCLS comm CYCL comm\n"); fprintf(stdout, TIMING_PREFIX "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f " "%4.2f\n", get_time(TimeTasks::MOMENTS), get_communicate(TimeTasks::MOMENTS), get_time(TimeTasks::FIELDS), get_communicate(TimeTasks::FIELDS), get_time(TimeTasks::PARTICLES), get_communicate(TimeTasks::PARTICLES), get_time(), get_communicate() ); fflush(stdout); } }