Parallel Rogue-like benchmark

bearophile bearophileHUGS at lycos.com
Fri Aug 23 06:48:38 PDT 2013


The author of the serial language comparison has now created a 
simple parallel comparison:

http://togototo.wordpress.com/2013/08/23/benchmarks-round-two-parallel-go-rust-d-scala-and-nimrod/

 From the blog post:

>but for the D and Rust implementations only the single-threaded 
>portion was written idiomatically; the parallelisation of that 
>code was done naively by myself.<

The single-threaded D version of the code is not idiomatic, it's 
very C-like code.

This was the idiomatic serial D version:
https://github.com/logicchains/levgen-benchmarks/blob/master/D-XorShift.d


Also the author keeps changing the way he measures languages, and 
in the meantime he has added the line count metric too, so now 
the D version should be modified so code like this takes 2 lines 
instead of 12:

struct Tile {
     int X = void;
     int Y = void;
     int T = void;
}

struct Room {
     int X = void;
     int Y = void;
     int W = void;
     int H = void;
     int N = void;
}


More from the blog post:

>The D implementation also surprised me, although I think this 
>was largely because I was unfamiliar with D’s memory model. I 
>originally tried having each thread write to part of a global 
>array, like in the C implementation, but, after they had 
>completed their task and the time came to read the data, the 
>array was empty, possibly having been garbage collected. The 
>solution was to mark the array as shared, which required 
>propagating the chain of ‘shared’ typing to the objects being 
>written to the array in order to ensure safety. This was an 
>interesting difference from Rust’s memory safety model, where 
>the type of pointers rather than objects determines how they can 
>be shared, but I’m not familiar enough with D’s memory model to 
>comment on their relative effectiveness.<

>I parallelised the D and Rust programs myself, hence the code is 
>probably not idiomatic, and still has plenty of room for 
>improvement. D for instance has a parallel for loop; I couldn’t 
>get it working, but if someone got it working then it would 
>significantly reduce the size of the code.<

Bye,
bearophile


More information about the Digitalmars-d mailing list