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

the graph stands for an iteration in a certain loop invocation (e.g., block 1.5 is iteration 5in the first invocation of loop L1). Typically, threads do not reach barriers at the same timefor a variety of reasons. For instance, each thread may be assigned different number ofiterations and the execution time of each iteration may vary. All threads are forced to stallat barriers after each parallel invocation, losing potential parallelism. Figure 1.4(b) showsa parallel execution plan after naïvely removing barriers. Without barriers, iterations frombefore and after a barrier may overlap, resulting in better performance.A few automatic parallelization techniques exploit cross-invocation parallelism [22,50, 72, 76]. Cross-invocation parallelization requires techniques for respecting crossinvocationdependences without resorting to coarse-grained barrier synchronization. Sometechniques [22, 76] respect dependences by combining several small loops into a singlelarger loop. This approach side-steps the problem of exploiting cross-invocation parallelismby converting it into cross-iteration parallelism. Other approaches [50, 72] carefullypartition the iteration space in each loop invocation so that cross-invocation dependencesare never split between threads. However, both techniques rely on static analyses. Consequently,they cannot adapt to the dependence patterns manifested by particular inputsat runtime. Many statically detected dependences may only manifest under certain inputconditions. For many programs, these dependences rarely manifest given the most commonprogram inputs. By adapting to the dependence patterns of specific inputs at runtime,programs can exploit additional cross-invocation parallelism to achieve greater scalability.6

main () {f();}f() {for (t = 0; t < TIMESTEP; t++) {L1: for (i = 0; i < M; i++) {A[i] = do_work(B[i], B[i+1]);}L2: for (j = 1; j < M+1; j++) {B[j] = do_work(A[j-1], A[j]);}}}(a) Sequential Programmain () {for (i = 0; i < NUM_THREADS; i++)create_thread(par_f, i);}par_f(threadID) {for (t = 0; t < TIMESTEP; t++) {L1: for (i = threadID; i < M; i=i+NUM_THREADS) {A[i] = do_work(B[i], B[i+1]);}pthread_barrier_wait(&barrier);L2: for (j = threadID; j < M+1; j=j+NUM_THREADS) {B[j] = do_work(A[j-1], A[j]);}pthread_barrier_wait(&barrier);}}(b) Parallelized ProgramFigure 1.3: Example of parallelizing a program with barriersWorker thread 1 Worker thread 2 Worker thread 3 Worker thread 4Worker thread 1 Worker thread 2 Worker thread 3 Worker thread 41.11.2 1.3 1.4L1Invocation 11.11.2 1.3 1.41.52.12.51.62.22.6Barrier2.3 2.42.72.8L2Invocation 11.52.12.53.11.62.22.63.22.32.72.42.83.13.53.23.6Barrier3.33.4L1Invocation 23.54.14.53.64.24.63.34.34.73.44.44.8Barrier4.14.24.64.34.74.44.8L2Invocation 2Time4.5(a) Parallel Execution with Barriers(b) Naïve Parallel Execution without BarriersFigure 1.4: Comparison between executions with and without barriers. A block with labelx.y represents the y th iteration in the x th loop invocation.7

main () {f();}f() {for (t = 0; t < TIMESTEP; t++) {L1: for (i = 0; i < M; i++) {A[i] = do_work(B[i], B[i+1]);}L2: for (j = 1; j < M+1; j++) {B[j] = do_work(A[j-1], A[j]);}}}(a) Sequential Programmain () {for (i = 0; i < NUM_THREADS; i++)create_thread(par_f, i);}par_f(threadID) {for (t = 0; t < TIMESTEP; t++) {L1: for (i = threadID; i < M; i=i+NUM_THREADS) {A[i] = do_work(B[i], B[i+1]);}pthread_barrier_wait(&barrier);L2: for (j = threadID; j < M+1; j=j+NUM_THREADS) {B[j] = do_work(A[j-1], A[j]);}pthread_barrier_wait(&barrier);}}(b) Parallelized ProgramFigure 1.3: Example of parallelizing a program with barriersWorker thread 1 Worker thread 2 Worker thread 3 Worker thread 4Worker thread 1 Worker thread 2 Worker thread 3 Worker thread 41.11.2 1.3 1.4L1Invocation 11.11.2 1.3 1.41.52.12.51.62.22.6Barrier2.3 2.42.72.8L2Invocation 11.52.12.53.11.62.22.63.22.32.72.42.83.13.53.23.6Barrier3.33.4L1Invocation 23.54.14.53.64.24.63.34.34.73.44.44.8Barrier4.14.24.64.34.74.44.8L2Invocation 2Time4.5(a) Parallel Execution with Barriers(b) Naïve Parallel Execution without BarriersFigure 1.4: Comparison between executions with and without barriers. A block with labelx.y represents the y th iteration in the x th loop <strong>invocation</strong>.7

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

Saved successfully!

Ooh no, something went wrong!