automatically exploiting cross-invocation parallelism using runtime ...

automatically exploiting cross-invocation parallelism using runtime ... automatically exploiting cross-invocation parallelism using runtime ...

dataspace.princeton.edu
from dataspace.princeton.edu More from this publisher
13.07.2015 Views

Main thread:main() {init();create_threads(threads, attrs, SpecCross_parallel_func, args);cleanup();}Worker thread:SpecCross_parallel_func(threadID) {for (t = 0; t < STEP; t++) {enter_barrier(threadID, "L1");L1: for (i = threadID; i < M; i = i + THREADNUM) {enter_task(threadID, minimum_distance_L1);spec_access(threadID, callback, &A[i], &C[i]);A[i] = do_work(B[C[i]]);exit_task(threadID);}enter_barrier(threadID, "L2");L2: for (j = threadID; j < M; j = j + THREADNUM) {enter_task(threadID, minimum_distance_L2);spec_access(threadID, callback, &C[D[j]], &A[j]);B[j] = do_work(A[D[j]]);exit_task(threadID);}}send_end_token(threadID);}Figure 4.9: Demonstration of using SPECCROSS runtime library in a parallel program5. Task Initialization. Function enter task is inserted before each task. It is notused in profiling mode.In speculation mode, it collects epoch number and tasknumber of worker threads other than the caller thread and sends the number pairsto the checker thread. The value of spec distance specifies the speculation distancebetween two tasks. This value is set according to the minimum distance returned bythe profiling run. The worker thread is stalled if it is executing beyond the minimumdistance compared to other worker threads.6. Task Finalization. Once a task completes execution, exit task is called. Inprofiling mode, this function logs the access signature of the task, compares this ac-68

cess signature with signatures of tasks executed by other threads in previous epochs.When detecting memory access conflicts, it records the dependence distance betweenpairs of conflicting tasks. After recording the minimum dependence distances betweenall conflicting tasks, it increments the task number. In speculation mode, itsimply increments the task number of the caller thread.7. Thread Completion. In speculation mode, after completing the execution of allepochs, function send end token sends an END TOKEN to the checker thread. Inprofiling mode, it does nothing.8. Enforcing Synchronization. Two functions, sync and checkpoint, can be insertedbefore any epoch to synchronize all threads or to do an extra checkpoint. Thisis useful when a certain epoch is known to cause conflicts or contain irreversible operations(e.g. I/O). Users can use sync to synchronize all threads before enteringthis epoch and do an extra checkpoint operation before starting the execution of thenext epoch.9. Speculation Finalization. Function cleanup is inserted at the end of the programwhich waits for worker threads and checker thread to exit and then frees memoryallocated for profiling or speculation.4.3 SPECCROSS Parallelizing CompilerSPECCROSS targets a code region composed of large amounts of parallel loop invocations.Often, such a code region is an outermost loop which contains multiple parallelizableinner loops. To locate these code regions, we analyze all hot loops within the sequentialprogram. A lot loop accounts for at least 10% of the overall execution time during the profilingrun. A hot loop is a candidate for SPECCROSS if it satisfies three conditions: first, theoutermost loop itself cannot be successfully parallelized by any parallelization technique69

cess signature with signatures of tasks executed by other threads in previous epochs.When detecting memory access conflicts, it records the dependence distance betweenpairs of conflicting tasks. After recording the minimum dependence distances betweenall conflicting tasks, it increments the task number. In speculation mode, itsimply increments the task number of the caller thread.7. Thread Completion. In speculation mode, after completing the execution of allepochs, function send end token sends an END TOKEN to the checker thread. Inprofiling mode, it does nothing.8. Enforcing Synchronization. Two functions, sync and checkpoint, can be insertedbefore any epoch to synchronize all threads or to do an extra checkpoint. Thisis useful when a certain epoch is known to cause conflicts or contain irreversible operations(e.g. I/O). Users can use sync to synchronize all threads before enteringthis epoch and do an extra checkpoint operation before starting the execution of thenext epoch.9. Speculation Finalization. Function cleanup is inserted at the end of the programwhich waits for worker threads and checker thread to exit and then frees memoryallocated for profiling or speculation.4.3 SPECCROSS Parallelizing CompilerSPECCROSS targets a code region composed of large amounts of parallel loop <strong>invocation</strong>s.Often, such a code region is an outermost loop which contains multiple parallelizableinner loops. To locate these code regions, we analyze all hot loops within the sequentialprogram. A lot loop accounts for at least 10% of the overall execution time during the profilingrun. A hot loop is a candidate for SPECCROSS if it satisfies three conditions: first, theoutermost loop itself cannot be successfully parallelized by any parallelization technique69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!