aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-04-03 13:39:16 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-04-03 13:39:16 +0000
commitc8333c0fd57213d3822dde13c51c387705af1681 (patch)
treee36eddc14c2be56980c947413909455e44f82cc1
parenta0eabb87e15f593e1c6ce583ee1f11112d94101d (diff)
downloadgcc-c8333c0fd57213d3822dde13c51c387705af1681.zip
gcc-c8333c0fd57213d3822dde13c51c387705af1681.tar.gz
gcc-c8333c0fd57213d3822dde13c51c387705af1681.tar.bz2
mt_allocator.h (__mt_alloc<>::allocate): Factor out some duplicated code.
2004-04-03 Paolo Carlini <pcarlini@suse.de> * include/ext/mt_allocator.h (__mt_alloc<>::allocate): Factor out some duplicated code. (__mt_alloc<>::_Bin_record): Spare the space of _M_free and _M_used in the single threaded case. * testsuite/performance/20_util/allocator/list_sort_search.cc: Reorder and renumber the tests consistently with the other testfiles. * testsuite/performance/20_util/allocator/map_mt_find.cc: Ditto. * testsuite/performance/20_util/allocator/map_thread.cc: Ditto. * testsuite/performance/20_util/allocator/producer_consumer.cc: Ditto. From-SVN: r80375
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/ext/mt_allocator.h38
-rw-r--r--libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc4
-rw-r--r--libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc4
-rw-r--r--libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc12
-rw-r--r--libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc30
6 files changed, 48 insertions, 52 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 3248c32..39cfd05 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2004-04-03 Paolo Carlini <pcarlini@suse.de>
+
+ * include/ext/mt_allocator.h (__mt_alloc<>::allocate): Factor out
+ some duplicated code.
+ (__mt_alloc<>::_Bin_record): Spare the space of _M_free and _M_used
+ in the single threaded case.
+ * testsuite/performance/20_util/allocator/list_sort_search.cc:
+ Reorder and renumber the tests consistently with the other testfiles.
+ * testsuite/performance/20_util/allocator/map_mt_find.cc: Ditto.
+ * testsuite/performance/20_util/allocator/map_thread.cc: Ditto.
+ * testsuite/performance/20_util/allocator/producer_consumer.cc: Ditto.
+
2004-04-02 Paolo Carlini <pcarlini@suse.de>
* include/ext/mt_allocator.h (__mt_alloc<>::deallocate):
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index d69b0e1..401fc3f 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -228,8 +228,8 @@ namespace __gnu_cxx
// Points to the block_record of the next free block.
_Block_record* volatile _M_next;
- // The thread id of the thread which has requested this block.
#ifdef __GTHREADS
+ // The thread id of the thread which has requested this block.
size_t _M_thread_id;
#endif
};
@@ -241,6 +241,7 @@ namespace __gnu_cxx
// for _S_max_threads + global pool 0.
_Block_record** volatile _M_first;
+#ifdef __GTHREADS
// An "array" of counters used to keep track of the amount of
// blocks that are on the freelist/used for each thread id.
// Memory to these "arrays" is allocated in _S_initialize() for
@@ -251,7 +252,6 @@ namespace __gnu_cxx
// Each bin has its own mutex which is used to ensure data
// integrity while changing "ownership" on a block. The mutex
// is initialized in _S_initialize().
-#ifdef __GTHREADS
__gthread_mutex_t* _M_mutex;
#endif
};
@@ -359,14 +359,6 @@ namespace __gnu_cxx
}
__gthread_mutex_unlock(__bin._M_mutex);
}
-
- // Return the first newly added block in our list and
- // update the counters
- __block = __bin._M_first[__thread_id];
- __bin._M_first[__thread_id] = __bin._M_first[__thread_id]->_M_next;
- __block->_M_thread_id = __thread_id;
- --__bin._M_free[__thread_id];
- ++__bin._M_used[__thread_id];
}
else
#endif
@@ -384,28 +376,20 @@ namespace __gnu_cxx
--__block_count;
}
__block->_M_next = NULL;
-
- // Remove from list.
- __block = __bin._M_first[0];
- __bin._M_first[0] = __bin._M_first[0]->_M_next;
}
}
- else
- {
- // "Default" operation - we have blocks on our own freelist
- // grab the first record and update the counters.
- __block = __bin._M_first[__thread_id];
- __bin._M_first[__thread_id] = __bin._M_first[__thread_id]->_M_next;
+ __block = __bin._M_first[__thread_id];
+ __bin._M_first[__thread_id] = __bin._M_first[__thread_id]->_M_next;
#ifdef __GTHREADS
- if (__gthread_active_p())
- {
- __block->_M_thread_id = __thread_id;
- --__bin._M_free[__thread_id];
- ++__bin._M_used[__thread_id];
- }
-#endif
+ if (__gthread_active_p())
+ {
+ __block->_M_thread_id = __thread_id;
+ --__bin._M_free[__thread_id];
+ ++__bin._M_used[__thread_id];
}
+#endif
+
char* __c = reinterpret_cast<char*>(__block) + sizeof(_Block_record);
return static_cast<_Tp*>(static_cast<void*>(__c));
}
diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc
index f39e814..317a615 100644
--- a/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc
+++ b/libstdc++-v3/testsuite/performance/20_util/allocator/list_sort_search.cc
@@ -116,10 +116,10 @@ int main ()
do_test<malloc_allocator<int> >();
#endif
#ifdef TEST_S2
- do_test<bitmap_allocator<int> >();
+ do_test<__mt_alloc<int> >();
#endif
#ifdef TEST_S3
- do_test<__mt_alloc<int> >();
+ do_test<bitmap_allocator<int> >();
#endif
#ifdef TEST_S4
do_test<__pool_alloc<int> >();
diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc
index 35bba56..2ee20f2 100644
--- a/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc
+++ b/libstdc++-v3/testsuite/performance/20_util/allocator/map_mt_find.cc
@@ -142,10 +142,10 @@ int main()
exec_tests<malloc_allocator<int> >();
#endif
#ifdef TEST_T2
- exec_tests<bitmap_allocator<int> >();
+ exec_tests<__mt_alloc<int> >();
#endif
#ifdef TEST_T3
- exec_tests<__mt_alloc<int> >();
+ exec_tests<bitmap_allocator<int> >();
#endif
#ifdef TEST_T4
exec_tests<__pool_alloc<int> >();
diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc
index 667d50b..c9cf34c 100644
--- a/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc
+++ b/libstdc++-v3/testsuite/performance/20_util/allocator/map_thread.cc
@@ -111,23 +111,23 @@ template<typename Container>
int main(void)
{
-#ifdef TEST_T1
+#ifdef TEST_T0
test_container(map<int, int>());
#endif
-#ifdef TEST_T2
+#ifdef TEST_T1
test_container(map<int, int, less<const int>, new_allocator<int> >());
#endif
-#ifdef TEST_T3
+#ifdef TEST_T2
test_container(map<int, int, less<const int>, malloc_allocator<int> >());
#endif
-#ifdef TEST_T4
+#ifdef TEST_T3
test_container(map<int, int, less<const int>,
__mt_alloc< pair<const int, int> > >());
#endif
-#ifdef TEST_T5
+#ifdef TEST_T4
test_container(map<int, int, less<const int>, bitmap_allocator<int> >());
#endif
-#ifdef TEST_T6
+#ifdef TEST_T5
test_container(map<int, int, less<const int>, __pool_alloc<int> >());
#endif
return 0;
diff --git a/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc b/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc
index 4e13a5c..98f39c19 100644
--- a/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc
+++ b/libstdc++-v3/testsuite/performance/20_util/allocator/producer_consumer.cc
@@ -290,51 +290,51 @@ template<typename Container>
int main(void)
{
-#ifdef TEST_T1
+#ifdef TEST_T0
test_container(vector<test_type, malloc_alloc_type>());
#endif
-#ifdef TEST_T2
+#ifdef TEST_T1
test_container(vector<test_type, new_alloc_type>());
#endif
-#ifdef TEST_T3
+#ifdef TEST_T2
test_container(vector<test_type, so_alloc_type>());
#endif
-#ifdef TEST_T4
+#ifdef TEST_T3
test_container(vector<test_type, bit_alloc_type>());
#endif
-#ifdef TEST_T5
+#ifdef TEST_T4
test_container(vector<test_type, po_alloc_type>());
#endif
-#ifdef TEST_T6
+#ifdef TEST_T5
test_container(list<test_type, malloc_alloc_type>());
#endif
-#ifdef TEST_T7
+#ifdef TEST_T6
test_container(list<test_type, new_alloc_type>());
#endif
-#ifdef TEST_T8
+#ifdef TEST_T7
test_container(list<test_type, so_alloc_type>());
#endif
-#ifdef TEST_T9
+#ifdef TEST_T8
test_container(list<test_type, bit_alloc_type>());
#endif
-#ifdef TEST_T10
+#ifdef TEST_T9
test_container(list<test_type, po_alloc_type>());
#endif
-#ifdef TEST_T11
+#ifdef TEST_T10
test_container(map<test_type, test_type, compare_type, malloc_alloc_type>());
#endif
-#ifdef TEST_T12
+#ifdef TEST_T11
test_container(map<test_type, test_type, compare_type, new_alloc_type>());
#endif
-#ifdef TEST_T13
+#ifdef TEST_T12
test_container(map<test_type, test_type, compare_type, so_alloc_type>());
#endif
-#ifdef TEST_T14
+#ifdef TEST_T13
test_container(map<test_type, test_type, compare_type, bit_alloc_type>());
#endif
-#ifdef TEST_T15
+#ifdef TEST_T14
test_container(map<test_type, test_type, compare_type, po_alloc_type>());
#endif