[Issue 12708] New: DMD threaded code running slower than single-threaded code
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon May 5 22:54:36 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12708
Issue ID: 12708
Summary: DMD threaded code running slower than single-threaded
code
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: regression
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: atila.neves at gmail.com
The program below runs slower with threads (no "-s" option) than in one thread
(with the "-s" option). The opposite happens when compiling with gdc, which is
the expected behaviour. Found with dmd 2.065 on Arch Linux 64-bit.
import std.parallelism;
import std.getopt;
import std.array;
import std.ascii;
import std.base64;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.cstream;
alias TestFunction = void function();
auto getTests(Modules...)() {
TestFunction[] tests;
foreach(mod; Modules) {
foreach(test; __traits(getUnitTests, mod)) {
tests ~= &test;
}
}
return tests;
}
void main(string[] args) {
bool single;
getopt(args,
"single|s", &single
);
enum tests = getTests!(
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.concurrency,
std.container,
std.cstream,
);
if(single) {
foreach(test; tests) {
test();
}
} else {
foreach(test; tests.parallel) {
test();
}
}
}
--
More information about the Digitalmars-d-bugs
mailing list