X-Spam-Check-By: sourceware.org Message-ID: <20060330133347.26691.qmail@web34802.mail.mud.yahoo.com> Date: Thu, 30 Mar 2006 05:33:47 -0800 (PST) From: Pete Subject: RE: segfault on memory intensive programs To: cygwin AT cygwin DOT com In-Reply-To: <062f01c653e4$cc9eb5c0$a501a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --- Dave Korn wrote: > On 29 March 2006 21:22, Pete wrote: > > > I have some benchmarkign code > > > > #define N 600 // Matrix rank > > #define ITERATIONS 2000 > > > > > > > > int main( void ) > > { > > // Set up the timer and start it ticking. > > Timer timer; > > timer.startTimer(); > > > > // We multiply m1 and m2, and put the result in > m3. > > int m1[N][N]; > > int m2[N][N]; > > int m3[N][N]; > > ... > > > > Your testcase didn't even compile for me! It > complained about those three dots! Hi Dave, Thanks for replying. Here's the rest of the code. It segfaults when N >= 417: #define N 600 // The dimension of the matrices #define ITERATIONS 2000 // Number of times to perform multiplication. #include "Timer.h" #include #include #include static void complain_and_die( void ); static int getInt( const int low, const int high ); static void fill_matrix( int m[][N] ); static void matrix_multiplication( const int a[][N], const int b[][N], int result[][N] ); int main( void ) { // Set up the timer and start it ticking. Timer timer; timer.startTimer(); // We multiply m1 and m2, and put the result in m3. int m1[N][N]; int m2[N][N]; int m3[N][N]; // Seed the random number generator srand( time(NULL) ); // Perform the multiplication ITERATIONS times. for ( int i = 0; i < ITERATIONS; ++i ) { fill_matrix( m1 ); fill_matrix( m2 ); matrix_multiplication( m1, m2, m3 ); } // Stop the timer and end the program. timer.endTimer(); timer.printStats(); return 0; } inline static void complain_and_die( void ) { fprintf( stderr, "I need the rank of the matrix\n" ); exit(1); } inline static int getInt( const int low, const int high ) { return low + ( rand() % (high - low + 1) ); } inline static void fill_matrix( int m[][N] ) { for ( int i = 0; i < N; ++i ) for ( int j = 0; j < N; ++j ) m[i][j] = getInt(0, 100); } inline static void matrix_multiplication( const int a[][N], const int b[][N], int result[][N] ) { for( int i = 0; i < N; ++i ) for( int j = 0; j < 3; ++j ) for( int k = 0; k < N ; ++k ) result[i][j] = a[i][k] + b[k][j]; } The executable is produced with: $ make g++ -W -Wall -O9 -funroll-loops -mtune=pentium4 -c -o matrix_mult_r.o matrix_mult_r.cc g++ -W -Wall -O9 -funroll-loops -mtune=pentium4 -c -o Timer.o Timer.cc g++ -o matrix_mult_r.exe *.o but it segfaults with and without the optimization flags. Pete __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/