forked from iscs-sssihl/2015
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.html
More file actions
44 lines (28 loc) · 8.18 KB
/
Copy pathtest1.html
File metadata and controls
44 lines (28 loc) · 8.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="http://moodle.rrze.uni-erlangen.de/moodle/theme/standard/styles_ie7.css" />
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="http://moodle.rrze.uni-erlangen.de/moodle/theme/standard/styles_ie6.css" />
<![endif]-->
<title>Exercise: Code optimization</title>
<!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://moodle.rrze.uni-erlangen.de/moodle/lib/csshover.htc);} /*]]>*/</style>-->
</head>
<body class="mod-resource course-256 dir-ltr lang-en_utf8" id="mod-resource-view">
<div id="page">
<div id="header" class=" clearfix"> <h1 class="headermain">SC12 Tutorial "The practitioner's cookbook for good parallel performance on multi- and manycore systems"</h1>
<div class="headermenu"><div class="navigation">
<ul>
code: <a href="./OPT.tar">OPT</a>
</div></div>
</div> <div class="navbar clearfix">
<!-- END OF HEADER -->
<div id="content" class=" clearfix"><div class="box generalbox generalboxcontent boxaligncenter clearfix">
<div class="box generalbox generalboxcontent boxaligncenter clearfix"><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);">Which optimization strategies would you suggest for the piece of code below? The code is contained in the <b><font face="courier new,courier,monospace">OPT/</font></b> subfolder, in F90 and C versions. You can build it with<br /><br /></span>
<p style="text-indent: 0in; background-color: rgb(250, 250, 250); margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed;"><font size="4" face="courier new,courier,monospace"><b><span style="vertical-align: baseline;">$ make <font size="4">OPT</font>_F.exe # Fortran build</span></b></font></p>
<p style="text-indent: 0in; background-color: rgb(250, 250, 250); margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed;"><font size="4" face="courier new,courier,monospace"><b><span style="vertical-align: baseline;">$ </span><span style="vertical-align: baseline;">make <font size="4">OPT</font>_C.exe # C build</span></b></font></p>
<p style="font-size: 16px; text-indent: 0in; font-family: arial,verdana,helvetica,sans-serif; background-color: rgb(250, 250, 250); margin-top: 0pt; margin-bottom: 0pt; margin-left: 0in; direction: ltr; unicode-bidi: embed;"><span style="vertical-align: baseline;"><br /></span></p><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);">Write down what you expect to give the best performance. You may test your work by performing benchmark runs.</span><br style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);" /><br style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);" /><hr style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250); width: 1489.45px; height: 2px;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">double mat[N][N], s[N][N], val;</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">int i, j, v[N];</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">//</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">// ... v[] and s[][] may be assumed to contain valid data</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">//</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">for(i=0; i<N ; ++i) {</span><br style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;" /><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); color: rgb(255, 255, 255); font-family: 'courier new',courier,monospace;"></span><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);"></span>
<div style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250); margin-left: 40px;"><span style="font-family: 'courier new',courier,monospace;">for(j=0; j<N; ++j) {</span><br style="font-family: 'courier new',courier,monospace;" />
<div style="margin-left: 40px;"><span style="color: rgb(255, 255, 255); font-family: 'courier new',courier,monospace;"></span><span style="font-family: 'courier new',courier,monospace;">val = (double)(v[i] % 256);</span><br style="font-family: 'courier new',courier,monospace;" /><span style="color: rgb(255, 255, 255); font-family: 'courier new',courier,monospace;"></span><span style="font-family: 'courier new',courier,monospace;">mat[j][i] = s[j][i]*(sin(val)*sin(val)-cos(val)*cos(val));</span><span style="color: rgb(255, 255, 255); font-family: 'courier new',courier,monospace;"></span><br /></div><span style="color: rgb(255, 255, 255); font-family: 'courier new',courier,monospace;"></span><span style="font-family: 'courier new',courier,monospace;">}</span><br style="font-family: 'courier new',courier,monospace;" /></div><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">}</span><br style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);" /><hr style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250); width: 1489.45px; height: 2px;" /><br style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);" /><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);">No assumptions about the size of </span><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">N</span><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);"> may be made. You may, however, assume that the code is part of a function that gets called very frequently. </span><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">s[][]</span><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);"> and </span><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">v[]</span><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);"> may change between calls, and all entries of </span><span style="font-size: 16.3636px; background-color: rgb(250, 250, 250); font-family: 'courier new',courier,monospace;">v[]</span><span style="font-family: arial,verdana,helvetica,sans-serif; font-size: 16.3636px; background-color: rgb(250, 250, 250);"> are positive.<br /><br /></span>Can you develop a performance model for your optimized code? What is the code balance for large N? What is the latency for evaluating the <font face="courier new,courier,monospace"><b>cos()</b></font> function?<br /><br /> </div> </div>
</div>
</body>
</html>