www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Problem Benchmarking HashSet from containers-em

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
At

https://github.com/nordlow/justd/blob/master/containers_ex.d

I want to benchmark Economic Modelings container packages.

Specifically HashSet with different allocators.

But when I try to use `LocalAllocator` defined as

     alias LocalAllocator = InSituRegion!(n, T.alignof);

at

https://github.com/nordlow/justd/blob/master/containers_ex.d#L59

in call to `hashSet`

     auto hx = iota!T(0, n).hashSet; // TODO Use LocalAllocator


https://github.com/nordlow/justd/blob/master/containers_ex.d#L60

it errors as:

containers_ex.d(17,38): Error: constructor 
containers.hashset.HashSet!(int, InSituRegion!(1048576LU, 4LU), 
generateHash, false).HashSet.this is not callable because it is 
annotated with  disable
/home/per/Work/justd/containers/hashset.d(366,20): Error: struct 
std.experimental.allocator.building_blocks.region.InSituRegion!(1048576LU,
4LU).InSituRegion is not copyable because it is annotated with  disable
/home/per/opt/x86_64-unknown-linux-gnu/dlang/linux/bin64/src/phobos/
td/conv.d(4096,13): Error: static assert  "Bucket cannot be emplaced from
(InSituRegion!(1048576LU, 4LU))."
/home/per/opt/x86_64-unknown-linux-gnu/dlang/linux/bin64/src/phobos/
td/conv.d(4161,18):        instantiated from here:
emplaceImpl!(InSituRegion!(1048576LU, 4LU))
/home/per/Work/justd/containers/hashset.d(293,19):        
instantiated from here: emplace!(Bucket, InSituRegion!(1048576LU, 
4LU))
containers_ex.d(17,16):        instantiated from here: 
HashSet!(int, InSituRegion!(1048576LU, 4LU), generateHash, false)
containers_ex.d(60,31):        instantiated from here: 
hashSet!(InSituRegion!(1048576LU, 4LU), Result)

Comint exited abnormally with code 1 at Thu Oct 22 13:55:25

What's wrong?
Oct 22 2015
next sibling parent reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Thursday, 22 October 2015 at 11:55:39 UTC, Nordlöw wrote:
 https://github.com/nordlow/justd/blob/master/containers_ex.d
The current GitHub of containers_ex.d (using dmd git master) version works if justd repo is cloned recursively.
Oct 22 2015
parent reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Thursday, 22 October 2015 at 11:57:37 UTC, Nordlöw wrote:
 On Thursday, 22 October 2015 at 11:55:39 UTC, Nordlöw wrote:
 https://github.com/nordlow/justd/blob/master/containers_ex.d
The current GitHub of containers_ex.d (using dmd git master) version works if justd repo is cloned recursively.
I updated https://github.com/nordlow/justd/blob/master/containers_ex.d as you say but now it errors as /home/per/Work/justd/containers/hashset.d(46,19): Error: struct std.experimental.allocator.building_blocks.region.InSituRegion!(1048576LU, 4LU).InSituRegion is not copyable because it is annotated with disable /home/per/Work/justd/containers/hashset.d(42,11): Error: incompatible types for ((allocator) !is (null)): 'InSituRegion!(1048576LU, 4LU)' and 'typeof(null)' /home/per/Work/justd/containers/hashset.d(366,20): Error: struct std.experimental.allocator.building_blocks.region.InSituRegion!(1048576LU, 4LU).InSituRegion is not copyable because it is annotated with disable /home/per/opt/x86_64-unknown-linux-gnu/dlang/linux/bin64/src/phobos/ td/conv.d(4096,13): Error: static assert "Bucket cannot be emplaced from (InSituRegion!(1048576LU, 4LU))." /home/per/opt/x86_64-unknown-linux-gnu/dlang/linux/bin64/src/phobos/ td/conv.d(4161,18): instantiated from here: emplaceImpl!(InSituRegion!(1048576LU, 4LU)) /home/per/Work/justd/containers/hashset.d(293,19): instantiated from here: emplace!(Bucket, InSituRegion!(1048576LU, 4LU)) containers_ex.d(34,24): instantiated from here: HashSet!(int, InSituRegion!(1048576LU, 4LU), generateHash, false) containers_ex.d(82,31): instantiated from here: hashSet!(InSituRegion!(1048576LU, 4LU), Result) Can't I use InSituRegion in this way?
Oct 22 2015
parent Brian Schott <briancschott gmail.com> writes:
On Thursday, 22 October 2015 at 22:06:47 UTC, Nordlöw wrote:
 Can't I use InSituRegion in this way?
No. InSituRegion is not copyable. Try creating a `HashSet!(InSituRegion*)` instead.
Oct 22 2015
prev sibling parent reply Justin Whear <justin economicmodeling.com> writes:
On Thu, 22 Oct 2015 11:55:37 +0000, Nordlöw wrote:

 What's wrong?
HashSet has a disabled default constructor; you need to supply the allocator instance to the constructor here https://github.com/nordlow/ justd/blob/master/containers_ex.d#L17
Oct 22 2015
parent reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Thursday, 22 October 2015 at 17:32:34 UTC, Justin Whear wrote:
 On Thu, 22 Oct 2015 11:55:37 +0000, Nordlöw wrote:

 What's wrong?
HashSet has a disabled default constructor; you need to supply the allocator instance to the constructor here https://github.com/nordlow/ justd/blob/master/containers_ex.d#L17
Doesn't work. If I change auto set = HashSet!(E, Allocator)(); to auto set = HashSet!(E, Allocator)(Allocator()); it errors as containers_ex.d(17,38): Error: constructor containers.hashset.HashSet!(const(int), Mallocator, generateHash, false).HashSet.this (ulong bucketCount) is not callable using argument types (Mallocator) containers_ex.d(30,16): Error: template instance containers_ex.hashSet!(Mallocator, const(int)[]) error instantiating containers_ex.d(35,5): Error: static assert (is(typeof(__error) == const(int)*)) is false My existing call to auto set = HashSet!(E, Allocator)(); works for Mallocator as in https://github.com/nordlow/justd/blob/master/containers_ex.d#L17 but not for InSituRegion!(1024*1024, T.alignof) Why? Please, help.
Oct 22 2015
parent Justin Whear <justin economicmodeling.com> writes:
On Thu, 22 Oct 2015 19:41:08 +0000, Nordlöw wrote:

 My existing call to
 
      auto set = HashSet!(E, Allocator)();
 
 works for Mallocator as in
 
 https://github.com/nordlow/justd/blob/master/containers_ex.d#L17
 
 but not for
 
      InSituRegion!(1024*1024, T.alignof)
 
 Why? Please, help.
The HashSet defines different constructors based on the nature of tha allocator: https://github.com/economicmodeling/containers/blob/master/src/containers/hashset.d#L30 Specifically, if the allocator has zero state (like Mallocator), you do not pass an instance. If the allocator does have state, like InSituRegion, you need to pass an instance to the container's constructor.
Oct 22 2015