int handle_zoom_box (Desktop * d, CEvent * cwevent) { Picture *p; set_current_from_pointer (d, cwevent); p = &(d->view[d->current_view].pic); if (cwevent->state & ControlMask) { if ((cwevent->button == Button1 && (cwevent->type == ButtonRelease || cwevent->type == ButtonPress)) || (cwevent->state & Button1Mask && cwevent->type == MotionNotify)) move_marker (p, cwevent); if (cwevent->button == Button2 && cwevent->type == ButtonRelease) remove_marker (p, cwevent); } else { if (cwevent->button == Button1 && cwevent->type == ButtonRelease) insert_marker (p, cwevent); if (cwevent->button == Button2 && cwevent->type == ButtonRelease) check_button_release (p, cwevent); } if (cwevent->type == MotionNotify || cwevent->type == ButtonRelease) return check_motion (p, cwevent); return 0; }
void pb_SwitchToTimer(struct pb_TimerSet *timers, enum pb_TimerID timer) { /* Stop the currently running timer */ if (timers->current != pb_TimerID_NONE) { struct pb_SubTimerList *subtimerlist = timers->sub_timer_list[timers->current]; struct pb_SubTimer *currSubTimer = (subtimerlist != NULL) ? subtimerlist->current : NULL; if (!is_async(timers->current) ) { if (timers->current != timer) { if (currSubTimer != NULL) { pb_StopTimerAndSubTimer(&timers->timers[timers->current], &currSubTimer->timer); } else { pb_StopTimer(&timers->timers[timers->current]); } } else { if (currSubTimer != NULL) { pb_StopTimer(&currSubTimer->timer); } } } else { insert_marker(timers, timer); if (!is_async(timer)) { // if switching to async too, keep driver going pb_StopTimer(&timers->timers[pb_TimerID_DRIVER]); } } } pb_Timestamp currentTime = get_time(); /* The only cases we check for asynchronous task completion is * when an overlapping CPU operation completes, or the next * segment blocks on completion of previous async operations */ if( asyncs_outstanding(timers) && (!is_async(timers->current) || is_blocking(timer) ) ) { struct pb_async_time_marker_list * last_event = get_last_async(timers); /* cudaSuccess if completed */ cudaError_t async_done = cudaEventQuery(*((cudaEvent_t *)last_event->marker)); if(is_blocking(timer)) { /* Async operations completed after previous CPU operations: * overlapped time is the total CPU time since this set of async * operations were first issued */ // timer to switch to is COPY or NONE if(async_done != cudaSuccess) accumulate_time(&(timers->timers[pb_TimerID_OVERLAP].elapsed), timers->async_begin,currentTime); /* Wait on async operation completion */ cudaEventSynchronize(*((cudaEvent_t *)last_event->marker)); pb_Timestamp total_async_time = record_async_times(timers); /* Async operations completed before previous CPU operations: * overlapped time is the total async time */ if(async_done == cudaSuccess) timers->timers[pb_TimerID_OVERLAP].elapsed += total_async_time; } else /* implies (!is_async(timers->current) && asyncs_outstanding(timers)) */ // i.e. Current Not Async (not KERNEL/COPY_ASYNC) but there are outstanding // so something is deeper in stack if(async_done == cudaSuccess) { /* Async operations completed before previous CPU operations: * overlapped time is the total async time */ timers->timers[pb_TimerID_OVERLAP].elapsed += record_async_times(timers); } } /* Start the new timer */ if (timer != pb_TimerID_NONE) { if(!is_async(timer)) { pb_StartTimer(&timers->timers[timer]); } else { // toSwitchTo Is Async (KERNEL/COPY_ASYNC) if (!asyncs_outstanding(timers)) { /* No asyncs outstanding, insert a fresh async marker */ insert_marker(timers, timer); timers->async_begin = currentTime; } else if(!is_async(timers->current)) { /* Previous asyncs still in flight, but a previous SwitchTo * already marked the end of the most recent async operation, * so we can rename that marker as the beginning of this async * operation */ struct pb_async_time_marker_list * last_event = get_last_async(timers); last_event->label = NULL; last_event->timerID = timer; } if (!is_async(timers->current)) { pb_StartTimer(&timers->timers[pb_TimerID_DRIVER]); } } } timers->current = timer; }