public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42194] New: performance degradation with STL complex convolution operation
@ 2009-11-27 12:02 jagjeet dot nain at gmail dot com
2009-11-27 15:02 ` [Bug c++/42194] " rguenth at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jagjeet dot nain at gmail dot com @ 2009-11-27 12:02 UTC (permalink / raw)
To: gcc-bugs
I have very simple program which basically does complex matrix convolution
operation.
I am seeing 3 times performance degradation if this program is compiled with
4.3.2 version vs compiled with 4.0.2. I am compiling this program with -O3
option, no additional optimization flags supplied. Also one more interesting
thing to note is that this behavior is seen only with complex data type, if i
use plain float data type, timings are better with 4.3.2 version.
Please help me.
#include <complex>
#include <iostream>
#include <stdio.h>
#include <time.h>
float procTimeInSeconds()
{
return clock()/static_cast<float>(CLOCKS_PER_SEC);
}
using namespace std;
int main(int argc , char** arg )
{
const int Nc = 32; // total matrix
const int Nx = 512; // columns
const int Nn = 16; //typical value
const int Ns = 10;
const int Nw = Nc * Nn;
complex<float>* all_weights = new complex<float>[Nx*Nw*Nc];
complex<float>* input = (complex<float>*)new complex<float>[Nx*Nw*Ns];
complex<float>* output = (complex<float>*)new complex<float>[Nx*Nc*Ns];
int weights_stride_c = Nx * Nw;
int weights_stride_w = Nx;
int weights_stride_x = 1;
int input_stride_s = Nx * Nw;
int input_stride_w = Nx;
int input_stride_x = 1;
int output_stride_s = Nx * Nc;
int output_stride_c = Nx;
int output_stride_x = 1;
// ================================================================
// Round 1
// Do array reductions as we decend into the loop nesting,
// keeping temporary pointers for each result.
// Results: Faster for unoptimized compilation, but slower for
// compiler optimization on.
// ================================================================
int count = 0;
float startTime = procTimeInSeconds();
complex<float>* input_s;
complex<float>* output_s ;
complex<float>* curr_weight_c;
complex<float>* output_sc;
complex<float>* curr_weight_cw;
complex<float>* input_sw;
for(int is = 0; is < Ns; ++is )
{
input_s = &input[is*input_stride_s];
output_s = &output[is*output_stride_s];
for (int ic=0; ic<Nc; ++ic)
{
curr_weight_c = &all_weights[ic * weights_stride_c];
output_sc = &output_s[ic*output_stride_c];
// for that matrix, loop through w
for (int iw=0; iw<Nw; ++iw)
{
curr_weight_cw = &curr_weight_c[weights_stride_w * iw];
input_sw = &input_s[iw*input_stride_w];
for (int ix=0; ix<Nx; ++ix)
{
output_sc[ix*output_stride_x] +=
curr_weight_cw[ix*weights_stride_x] * input_sw[ix*input_stride_x];
++count;
}
}
}
}
//delete [] all_weights;
float netTime = procTimeInSeconds() - startTime;
cout << count << " in " << netTime << " seconds, round 1" << std::endl;
return 0;
}
--
Summary: performance degradation with STL complex convolution
operation
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jagjeet dot nain at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42194
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-23 21:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-42194-4@http.gcc.gnu.org/bugzilla/>
2011-09-23 21:54 ` [Bug c++/42194] performance degradation with STL complex convolution operation paolo.carlini at oracle dot com
2009-11-27 12:02 [Bug c++/42194] New: " jagjeet dot nain at gmail dot com
2009-11-27 15:02 ` [Bug c++/42194] " rguenth at gcc dot gnu dot org
2009-11-30 9:57 ` jagjeet dot nain at gmail dot com
2010-01-10 5:54 ` jagjeet dot nain at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).