there are so many cores

Just another WordPress.com site

Nested loop rolling is easy

Basic loop rolling isn’t difficult.

Here’s a simple example:

Arrayf64 A = make1(100, cpuA);
Arrayf64 B = 5;

for (size_t i = 0; i < 2; i++)
{
    for (size_t j = 0; j < 3; j++)
    {
        A = A + B;
    }

    B = B + 1;
}

Loop rolling is done in three passes:

ORIGINAL TRACE             PASS 1                         PASS 2                         PASS 3

0.0                        0.0                            0.0                            0.0  
0.1  13 PTR ( 0x24dca40 )  0.1  13 PTR ( 0x24dca40 )      0.1  13 PTR ( 0x24dca40 )      0.1  13 PTR ( 0x24dca40 )
1.0                        1.0                            1.0                            1.0  
1.1  50 5                  1.1  50 5                      1.1  50 5                      1.1  50 5
0.2  3 25 0.1 1.1          repeat compound stmt 3 times:  repeat compound stmt 3 times:  repeat compound stmt 2 times:
0.3  3 25 0.2 1.1            0  3 25 0.1 1.1                0  3 25 0.1 1.1                repeat compound stmt 3 times:
0.4  3 25 0.3 1.1                                                                            0  3 25 0.1 1.1
1.2  3 25 1.1 49 1         1.2  3 25 1.1 49 1             1.2  3 25 1.1 49 1               1  3 25 1.1 49 1
0.5  3 25 0.4 1.2          0.5  3 25 0.4 1.2              repeat compound stmt 3 times:
0.6  3 25 0.5 1.2          0.6  3 25 0.5 1.2                0  3 25 0.4 1.2
0.7  3 25 0.6 1.2          0.7  3 25 0.6 1.2
1.3  3 25 1.2 49 1         1.3  3 25 1.2 49 1             1.3  3 25 1.2 49 1
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: