-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmarks_2fft_8cpp-example.htm
More file actions
166 lines (166 loc) · 10.2 KB
/
benchmarks_2fft_8cpp-example.htm
File metadata and controls
166 lines (166 loc) · 10.2 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!-- HTML header for doxygen 1.9.5-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130950618-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-130950618-1');
</script>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.5"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ArrayFire: benchmarks/fft.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="arrayfire.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript" src="doxygen-awesome-fragment-copy-button.js"></script>
<script type="text/javascript" src="doxygen-awesome-interactive-toc.js"></script>
<script type="text/javascript">
DoxygenAwesomeDarkModeToggle.init()
DoxygenAwesomeInteractiveToc.init()
DoxygenAwesomeFragmentCopyButton.init()
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="2" cellpadding="2" width="100%">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><a href="index.htm"><img alt="Logo" src="arrayfire_logo.png"/></a></td>
</tr>
<tr id="projectrow">
<td>
<div id="projectbrief">A high-performance general-purpose compute library</div>
</td>
</tr>
<!--END !PROJECT_NAME-->
<div>
<td id="gsearch">
<script async src="https://cse.google.com/cse.js?cx=004356362924927882526:zup3ehe-7bs"></script>
<div class="gcse-search"></div>
</td>
</div>
</tr>
<tr>
<td>
<div id="togglediv"></div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part --><!-- Generated by Doxygen 1.9.5 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.htm"><span>Main Page</span></a></li>
<li><a href="tutorials.htm"><span>Tutorials</span></a></li>
<li><a href="modules.htm"><span>Functions</span></a></li>
<li><a href="releasenotes.htm"><span>Release Notes</span></a></li>
<li><a href="examples.htm"><span>Examples</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(document).ready(function(){initNavTree('benchmarks_2fft_8cpp-example.htm',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle"><div class="title">benchmarks/fft.cpp</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><span class="comment">/*******************************************************</span></div>
<div class="line"><span class="comment"> * Copyright (c) 2014, ArrayFire</span></div>
<div class="line"><span class="comment"> * All rights reserved.</span></div>
<div class="line"><span class="comment"> *</span></div>
<div class="line"><span class="comment"> * This file is distributed under 3-clause BSD license.</span></div>
<div class="line"><span class="comment"> * The complete license agreement can be obtained at:</span></div>
<div class="line"><span class="comment"> * http://arrayfire.com/licenses/BSD-3-Clause</span></div>
<div class="line"><span class="comment"> ********************************************************/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include <<a class="code" href="arrayfire_8h.htm">arrayfire.h</a>></span></div>
<div class="line"><span class="preprocessor">#include <math.h></span></div>
<div class="line"><span class="preprocessor">#include <stdio.h></span></div>
<div class="line"><span class="preprocessor">#include <cstdlib></span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span><a class="code hl_namespace" href="namespaceaf.htm">af</a>;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// create a small wrapper to benchmark</span></div>
<div class="line"><span class="keyword">static</span> <a id="_a0" name="_a0"></a><a class="code hl_class" href="classaf_1_1array.htm">array</a> A; <span class="comment">// populated before each timing</span></div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> fn() {</div>
<div class="line"> <a class="code hl_class" href="classaf_1_1array.htm">array</a> B = fft2(A); <span class="comment">// 2d fft</span></div>
<div class="line"> B.<a id="a1" name="a1"></a><a class="code hl_function" href="classaf_1_1array.htm#a6a8d7156cd3c66a9ca9f0f2688ee9f72">eval</a>(); <span class="comment">// ensure evaluated</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>** argv) {</div>
<div class="line"> <span class="keywordflow">try</span> {</div>
<div class="line"> <span class="keywordtype">int</span> device = argc > 1 ? atoi(argv[1]) : 0;</div>
<div class="line"> setDevice(device);</div>
<div class="line"> info();</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">"Benchmark N-by-N 2D fft\n"</span>);</div>
<div class="line"> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> M = 7; M <= 12; M++) {</div>
<div class="line"> <span class="keywordtype">int</span> N = (1 << M);</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">"%4d x %4d: "</span>, N, N);</div>
<div class="line"> A = randu(N, N);</div>
<div class="line"> <span class="keywordtype">double</span> time = timeit(fn); <span class="comment">// time in seconds</span></div>
<div class="line"> <span class="keywordtype">double</span> gflops = 10.0 * N * N * M / (time * 1e9);</div>
<div class="line"> </div>
<div class="line"> printf(<span class="stringliteral">" %4.0f Gflops\n"</span>, gflops);</div>
<div class="line"> fflush(stdout);</div>
<div class="line"> }</div>
<div class="line"> } <span class="keywordflow">catch</span> (<a id="_a2" name="_a2"></a><a class="code hl_class" href="classaf_1_1exception.htm">af::exception</a>& e) { fprintf(stderr, <span class="stringliteral">"%s\n"</span>, e.<a id="a3" name="a3"></a><a class="code hl_function" href="classaf_1_1exception.htm#aa884ff67408851f00e50cf971a4dfd05">what</a>()); }</div>
<div class="line"> </div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="aarrayfire_8h_htm"><div class="ttname"><a href="arrayfire_8h.htm">arrayfire.h</a></div></div>
<div class="ttc" id="aclassaf_1_1array_htm"><div class="ttname"><a href="classaf_1_1array.htm">af::array</a></div><div class="ttdoc">A multi dimensional data container.</div><div class="ttdef"><b>Definition:</b> <a href="array_8h_source.htm#l00037">array.h:37</a></div></div>
<div class="ttc" id="aclassaf_1_1array_htm_a6a8d7156cd3c66a9ca9f0f2688ee9f72"><div class="ttname"><a href="classaf_1_1array.htm#a6a8d7156cd3c66a9ca9f0f2688ee9f72">af::array::eval</a></div><div class="ttdeci">void eval() const</div><div class="ttdoc">Evaluate any JIT expressions to generate data for the array.</div></div>
<div class="ttc" id="aclassaf_1_1exception_htm"><div class="ttname"><a href="classaf_1_1exception.htm">af::exception</a></div><div class="ttdoc">An ArrayFire exception class.</div><div class="ttdef"><b>Definition:</b> <a href="exception_8h_source.htm#l00021">exception.h:22</a></div></div>
<div class="ttc" id="aclassaf_1_1exception_htm_aa884ff67408851f00e50cf971a4dfd05"><div class="ttname"><a href="classaf_1_1exception.htm#aa884ff67408851f00e50cf971a4dfd05">af::exception::what</a></div><div class="ttdeci">virtual const char * what() const</div><div class="ttdoc">Returns an error message for the exception in a string format.</div><div class="ttdef"><b>Definition:</b> <a href="exception_8h_source.htm#l00046">exception.h:46</a></div></div>
<div class="ttc" id="anamespaceaf_htm"><div class="ttname"><a href="namespaceaf.htm">af</a></div><div class="ttdef"><b>Definition:</b> <a href="algorithm_8h_source.htm#l00014">algorithm.h:15</a></div></div>
</div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.9.3-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.5 </li>
</ul>
</div>
</body>
</html>