From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16531 invoked by alias); 13 Nov 2007 08:42:05 -0000 Received: (qmail 16515 invoked by uid 22791); 13 Nov 2007 08:42:04 -0000 X-Spam-Check-By: sourceware.org Received: from iramx2.ira.uni-karlsruhe.de (HELO iramx2.ira.uni-karlsruhe.de) (141.3.10.81) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 13 Nov 2007 08:42:01 +0000 Received: from irams2.ira.uni-karlsruhe.de ([141.3.10.82]) by iramx2.ira.uni-karlsruhe.de with esmtps id 1IrrLI-0006fp-Jx; Tue, 13 Nov 2007 09:41:59 +0100 Received: from irams1.ira.uni-karlsruhe.de ([141.3.10.5]) by irams2.ira.uni-karlsruhe.de with esmtps id 1IrrLH-00050A-5j; Tue, 13 Nov 2007 09:41:56 +0100 Received: from i10pc67.ilkd.uni-karlsruhe.de ([141.3.24.67]) by irams1.ira.uni-karlsruhe.de with esmtp id 1IrrLG-0003cl-SW; Tue, 13 Nov 2007 09:41:54 +0100 Message-ID: <47396352.3080706@ira.uka.de> Date: Tue, 13 Nov 2007 11:07:00 -0000 From: Johannes Singler User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: libstdc++ , gcc-patches@gcc.gnu.org Subject: [PATCH][libstdc++-v3 parallel mode] Content-Type: multipart/mixed; boundary="------------060003080304040205070301" X-Spam-Score: -1.4 (-) X-Spam-Report: -1.4 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 AWL AWL: From: address is in the auto white-list X-Spam-Host: irams2.ira.uni-karlsruhe.de X-ATIS-Checksum: v3zoCAcc32ckk X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg00692.txt.bz2 This is a multi-part message in MIME format. --------------060003080304040205070301 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 429 Fixes two small bugs concerning (partial) sort in parallel mode. Tested, no regressions on x86_64-unknown-linux-gnu. Please approve. 2007-11-13 Johannes Singler * include/parallel/multiway_merge.h: More robust finding of an arbitrary existing element inside the input sequences. * include/bits/stl_algo.h: Fix typo to actually call appropriate sequential version. Johannes --------------060003080304040205070301 Content-Type: text/plain; name="multiway_merge_no_default_constructor" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="multiway_merge_no_default_constructor" Content-length: 2816 Index: include/parallel/multiway_merge.h =================================================================== --- include/parallel/multiway_merge.h (revision 129922) +++ include/parallel/multiway_merge.h (working copy) @@ -900,25 +900,34 @@ difference_type total_length = 0; // Default value for potentially non-default-constructible types. - value_type* defaultcons = NULL; + value_type* arbitrary_element = NULL; + for (int t = 0; t < k; t++) { - if (stable) - { - if (seqs_begin[t].first == seqs_begin[t].second) - lt.insert_start_stable(*defaultcons, t, true); - else - lt.insert_start_stable(*seqs_begin[t].first, t, false); - } - else - { - if (seqs_begin[t].first == seqs_begin[t].second) - lt.insert_start(*defaultcons, t, true); - else - lt.insert_start(*seqs_begin[t].first, t, false); - } + if(arbitrary_element == NULL && LENGTH(seqs_begin[t]) > 0) + arbitrary_element = &(*seqs_begin[t].first); + total_length += LENGTH(seqs_begin[t]); + } - total_length += LENGTH(seqs_begin[t]); + if(total_length == 0) + return target; + + for (int t = 0; t < k; t++) + { + if (stable) + { + if (seqs_begin[t].first == seqs_begin[t].second) + lt.insert_start_stable(*arbitrary_element, t, true); + else + lt.insert_start_stable(*seqs_begin[t].first, t, false); + } + else + { + if (seqs_begin[t].first == seqs_begin[t].second) + lt.insert_start(*arbitrary_element, t, true); + else + lt.insert_start(*seqs_begin[t].first, t, false); + } } if (stable) @@ -941,7 +950,7 @@ // Feed. if (seqs_begin[source].first == seqs_begin[source].second) - lt.delete_min_insert_stable(*defaultcons, true); + lt.delete_min_insert_stable(*arbitrary_element, true); else // Replace from same source. lt.delete_min_insert_stable(*seqs_begin[source].first, false); @@ -959,7 +968,7 @@ // Feed. if (seqs_begin[source].first == seqs_begin[source].second) - lt.delete_min_insert(*defaultcons, true); + lt.delete_min_insert(*arbitrary_element, true); else // Replace from same source. lt.delete_min_insert(*seqs_begin[source].first, false); Index: include/bits/stl_algo.h =================================================================== --- include/bits/stl_algo.h (revision 129922) +++ include/bits/stl_algo.h (working copy) @@ -2028,7 +2028,7 @@ { if (__depth_limit == 0) { - _GLIBCXX_STD_P:partial_sort(__first, __last, __last); + _GLIBCXX_STD_P::partial_sort(__first, __last, __last); return; } --__depth_limit; --------------060003080304040205070301--