Commit 8d4addde by Benjamin Kosnik Committed by Benjamin Kosnik

tune-1.cc: Clarify for single-thread.


2005-09-23  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/ext/mt_allocator/tune-1.cc: Clarify for single-thread.
	* testsuite/ext/mt_allocator/tune-2.cc: Same.
	* testsuite/ext/mt_allocator/tune-3.cc: Same.
	* testsuite/ext/mt_allocator/tune-4.cc: Same.

From-SVN: r104591
parent 04f98580
2005-09-23 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/ext/mt_allocator/tune-1.cc: Clarify for single-thread.
* testsuite/ext/mt_allocator/tune-2.cc: Same.
* testsuite/ext/mt_allocator/tune-3.cc: Same.
* testsuite/ext/mt_allocator/tune-4.cc: Same.
2005-09-21 Guillaume Melquiond <guillaume.melquiond@ens-lyon.fr> 2005-09-21 Guillaume Melquiond <guillaume.melquiond@ens-lyon.fr>
PR libstdc++/23956 PR libstdc++/23956
......
...@@ -23,42 +23,42 @@ ...@@ -23,42 +23,42 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <testsuite_character.h> #include <testsuite_character.h>
#ifdef __GTHREADS
#define __cxxthread true
#else
#define __cxxthread false
#endif
// Tune characteristics. // Tune characteristics.
// __common_pool_policy // __common_pool_policy
void test01() void test01()
{ {
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
typedef __gnu_test::pod_int value_type;
using __gnu_cxx::__pool; using __gnu_cxx::__pool;
using __gnu_cxx::__common_pool_policy; using __gnu_cxx::__common_pool_policy;
#ifdef __GTHREADS typedef __gnu_test::pod_int value_type;
typedef __common_pool_policy<__pool, true> policy_type; typedef __common_pool_policy<__pool, __cxxthread> policy_type;
#else
typedef __common_pool_policy<__pool, false> policy_type;
#endif
typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type; typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
typedef __gnu_cxx::__pool_base::_Tune tune_type; typedef __gnu_cxx::__pool_base::_Tune tune_type;
tune_type t_default;
tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
allocator_type a; allocator_type a;
tune_type t1 = a._M_get_options(); tune_type t_default = a._M_get_options();
VERIFY( t1._M_align == t_default._M_align ); tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
tune_type t1 = t_default;
a._M_set_options(t_opt); a._M_set_options(t_opt);
tune_type t2 = a._M_get_options(); tune_type t2 = a._M_get_options();
VERIFY( t1._M_align != t2._M_align ); VERIFY( t1._M_align != t2._M_align );
allocator_type::pointer p1 = a.allocate(128); allocator_type::pointer p1 = a.allocate(128);
allocator_type::pointer p2 = a.allocate(5128); allocator_type::pointer p2 = a.allocate(5128);
a._M_set_options(t_single); a._M_set_options(t_small);
t1 = a._M_get_options(); tune_type t3 = a._M_get_options();
VERIFY( t1._M_max_threads != t_single._M_max_threads ); VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
VERIFY( t1._M_max_threads == t_opt._M_max_threads ); VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
a.deallocate(p1, 128); a.deallocate(p1, 128);
a.deallocate(p2, 5128); a.deallocate(p2, 5128);
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <testsuite_character.h> #include <testsuite_character.h>
#ifdef __GTHREADS
#define __cxxthread true
#else
#define __cxxthread false
#endif
// Tune characteristics. // Tune characteristics.
// __per_type_pool_policy // __per_type_pool_policy
void test02() void test02()
...@@ -34,19 +40,15 @@ void test02() ...@@ -34,19 +40,15 @@ void test02()
using __gnu_cxx::__pool; using __gnu_cxx::__pool;
using __gnu_cxx::__per_type_pool_policy; using __gnu_cxx::__per_type_pool_policy;
#ifdef __GTHREADS typedef __per_type_pool_policy<value_type, __pool, __cxxthread> policy_type;
typedef __per_type_pool_policy<value_type, __pool, true> policy_type;
#else
typedef __per_type_pool_policy<value_type, __pool, false> policy_type;
#endif
typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type; typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
typedef __gnu_cxx::__pool_base::_Tune tune_type; typedef __gnu_cxx::__pool_base::_Tune tune_type;
tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
allocator_type a; allocator_type a;
tune_type t_default = a._M_get_options(); tune_type t_default = a._M_get_options();
tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
tune_type t1 = t_default; tune_type t1 = t_default;
a._M_set_options(t_opt); a._M_set_options(t_opt);
tune_type t2 = a._M_get_options(); tune_type t2 = a._M_get_options();
...@@ -54,10 +56,10 @@ void test02() ...@@ -54,10 +56,10 @@ void test02()
allocator_type::pointer p1 = a.allocate(128); allocator_type::pointer p1 = a.allocate(128);
allocator_type::pointer p2 = a.allocate(5128); allocator_type::pointer p2 = a.allocate(5128);
a._M_set_options(t_single); a._M_set_options(t_small);
t1 = a._M_get_options(); tune_type t3 = a._M_get_options();
VERIFY( t1._M_max_threads != t_single._M_max_threads ); VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
VERIFY( t1._M_max_threads == t_opt._M_max_threads ); VERIFY( t3._M_chunk_size == t_opt._M_chunk_size );
a.deallocate(p1, 128); a.deallocate(p1, 128);
a.deallocate(p2, 5128); a.deallocate(p2, 5128);
......
// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com> // 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
// //
// Copyright (C) 2004 Free Software Foundation, Inc. // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -49,38 +49,33 @@ void test03() ...@@ -49,38 +49,33 @@ void test03()
typedef _Cp policy_type; typedef _Cp policy_type;
typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type; typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
// First instances assured.
allocator_type a; allocator_type a;
tune_type t_default = a._M_get_options(); tune_type t_default = a._M_get_options();
tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
// First instances assured.
tune_type t1 = t_default; tune_type t1 = t_default;
tune_type t2;
if (test_policy<policy_type>::per_type()) if (test_policy<policy_type>::per_type())
{ {
VERIFY( t1._M_align == t_default._M_align );
a._M_set_options(t_opt); a._M_set_options(t_opt);
t2 = a._M_get_options(); t1 = a._M_get_options();
VERIFY( t1._M_align != t2._M_align ); VERIFY( t1._M_align != t_default._M_align );
} }
else
t2 = t1;
// Lock tune settings. // Lock tune settings.
typename allocator_type::pointer p1 = a.allocate(128); typename allocator_type::pointer p1 = a.allocate(128);
allocator_type a2; allocator_type a2;
tune_type t3 = a2._M_get_options(); tune_type t2 = a2._M_get_options();
tune_type t4; VERIFY( t2._M_chunk_size == t1._M_chunk_size );
VERIFY( t3._M_max_threads == t2._M_max_threads );
typename allocator_type::pointer p2 = a2.allocate(5128); typename allocator_type::pointer p2 = a2.allocate(5128);
a2._M_set_options(t_single); a2._M_set_options(t_small);
t4 = a2._M_get_options(); tune_type t3 = a2._M_get_options();
VERIFY( t4._M_max_threads != t_single._M_max_threads ); VERIFY( t3._M_chunk_size != t_small._M_chunk_size );
VERIFY( t4._M_max_threads == t3._M_max_threads ); VERIFY( t3._M_chunk_size == t2._M_chunk_size );
a.deallocate(p1, 128); a.deallocate(p1, 128);
a2.deallocate(p2, 5128); a2.deallocate(p2, 5128);
......
// 2004-08-25 Benjamin Kosnik <bkoz@redhat.com> // 2004-08-25 Benjamin Kosnik <bkoz@redhat.com>
// //
// Copyright (C) 2004 Free Software Foundation, Inc. // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -54,52 +54,46 @@ void test04() ...@@ -54,52 +54,46 @@ void test04()
typedef __gnu_cxx::__pool_base::_Tune tune_type; typedef __gnu_cxx::__pool_base::_Tune tune_type;
typedef _Tp value_type; typedef _Tp value_type;
typedef _Cp policy_type; typedef _Cp policy_type;
typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type; typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
allocator_type a; allocator_type a;
tune_type t_default = a._M_get_options(); tune_type t_default = a._M_get_options();
tune_type t_opt(32, 5120, 32, 5120, 20, 10, false);
tune_type t_small(16, 1024, 32, 2048, 1, 10, false);
// First instance of local type assured.
tune_type t1 = t_default; tune_type t1 = t_default;
tune_type t2;
if (test_policy<policy_type>::per_type()) if (test_policy<policy_type>::per_type())
{ {
a._M_set_options(t_opt); a._M_set_options(t_opt);
t2 = a._M_get_options(); t1 = a._M_get_options();
VERIFY( t1._M_align != t2._M_align ); VERIFY( t1._M_align != t_default._M_align );
} }
else
t2 = t1;
// Lock tune settings. // Lock tune settings.
typename allocator_type::pointer p1 = a.allocate(128); typename allocator_type::pointer p1 = a.allocate(128);
// First instance of local type assured.
typedef pod2 value2_type; typedef pod2 value2_type;
typedef typename allocator_type::template rebind<value2_type>::other rebind_type; typedef typename allocator_type::template rebind<value2_type>::other rebind_type;
rebind_type a2; rebind_type a2;
tune_type t3 = a2._M_get_options(); tune_type t2 = a2._M_get_options();
tune_type t4;
// Both policy_type and rebind_type::policy_type have same characteristics. // Both policy_type and rebind_type::policy_type have same characteristics.
if (test_policy<policy_type>::per_type()) if (test_policy<policy_type>::per_type())
{ {
a2._M_set_options(t_opt); a2._M_set_options(t_opt);
t4 = a2._M_get_options(); tune_type t = a2._M_get_options();
VERIFY( t3._M_align != t4._M_align ); VERIFY( t2._M_align != t._M_align );
t3 = t4; t2 = t;
} }
else
VERIFY( t3._M_max_threads == t2._M_max_threads );
typename rebind_type::pointer p2 = a2.allocate(5128); typename rebind_type::pointer p2 = a2.allocate(5128);
a2._M_set_options(t_single); a2._M_set_options(t_small);
t4 = a2._M_get_options(); tune_type t4 = a2._M_get_options();
VERIFY( t4._M_max_threads != t_single._M_max_threads ); VERIFY( t4._M_chunk_size != t_small._M_chunk_size );
VERIFY( t4._M_max_threads == t3._M_max_threads ); VERIFY( t4._M_chunk_size == t2._M_chunk_size );
a.deallocate(p1, 128); a.deallocate(p1, 128);
a2.deallocate(p2, 5128); a2.deallocate(p2, 5128);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment