Problem with libstdc++ in GCC 4.4.0 port to interix
Robert Oeffner
robert@oeffner.net
Thu Oct 1 07:46:00 GMT 2009
Hi,
Still trying to solve the problems porting libstdc++ in GCC 4.4.0 to interix
I notice that when I compile the test code below with
flags -fopenmp -D_GLIBCXX_PARALLEL -O3 it works as expected at a decent
speed. But if I omit the _GLIBCXX_PARALLEL flag then the weird behaviour
with high CPU kernel times and slow execution occures whenever more than one
thread is requested in the program.
Are there any libstdc++ gurus out there who knows what these symptoms might
mean?
On a related note I see that among the source files in
gcc-4.4.0/libstdc++-v3/config/os ctype_base is implemented for most
platforms but interix. Does anyone know what is needed to write an interix
implementation for ctype_base or are there a set of defaults that are being
used?
Many thanks,
Rob
--------------------------------------------------
From: "Robert Oeffner" <robert@oeffner.net>
Sent: Wednesday, September 23, 2009 10:26 AM
To: <libstdc++@gcc.gnu.org>
Subject: Problem with libstdc++ in GCC 4.4.0 port to interix
> Hi,
>
> Probably a long shot but I wonder if anyone would have a useful tip on a
> problem porting gcc4.4.0 to interix (a BSD-like OS running on top of the
> Windows kernel).
>
> As libgomp in GCC so far isn't targeting interix I have made some changes
> to libgomp in my copy of the GCC 4.4.0
> distribution. A new source file was created,
> gcc-4.4.0/libgomp/config/posix/interix/proc.c, which is templated on the
> existing gcc-4.4.0/libgomp/config/posix/proc.c and
> gcc-4.4.0/libgomp/config/posix/mingw32/proc.c in the distribution (see
> http://www.oeffner.net/stuff/gcc-4.4.0_interix_changes.zip or
> http://www.suacommunity.com/forum/tm.aspx?m=16600 ). With this file and
> modifications to GCC configuration files in the distribution I can
> bootstrap GCC 4.4.0 to build gcc and g++ compilers on interix.
>
> The port produces fast code for single threaded running programs. However,
> there's a major problem with OpenMP. It's something to do with libstdc++
> that tends to go in overdrive when you request OpenMP to create more than
> one thread for the compiled program. When calling string.erase() from
> libstdc++ it somehow hogs the CPU with high kernel times and runs orders
> of magnitudes slower. The code below demonstrates the problem. It runs
> fast when using just one thread but abysmally slow when two or more
> threads are present, even though the loop doing the work is actually
> single threaded. Windows Taskmanager shows that execution times is roughly
> 50% kernel and 50% user time whenever you run more than one thread.
> Invoked with a single thread all execution times is just spend in user
> mode.
>
> If there is anyone here on this list who has a good suggestion that would
> be much appreciated.
>
> Many thanks,
>
> Rob
>
>
> #include <iostream>
> #include <omp.h>
>
> using namespace std;
>
> const long lmax = 50000;
>
>
> int main()
> {
> int nthreads = 1;
> cout<<"Enter number of OpenMP threads to create: ";
> cin >> nthreads;
> omp_set_num_threads(nthreads);
>
> #pragma omp parallel
> {
> #pragma omp single
> cout << "Doing string stuff with "<<omp_get_num_threads()<<"
> thread(s)"<<endl;
> }
>
>
> time_t start, now;
> time( &start );
>
> string pairlbl("");
>
> for (long m = 0; m< lmax; m++)
> {
> if ((m % (lmax/20))==0)
> cout << "m = "<<m<<endl;
>
> for (int j=1;j<=2000;j++)
> {
> pairlbl.clear();
> }
> }
>
> time( &now);
> cout<<"\ntime= "<<difftime( now, start )<<" sec\n";
>
> return 0;
> }
>
>
>
More information about the Libstdc++
mailing list