On 2013-03-01 22:05, Sparsh Mittal wrote:
On Friday, 1 March 2013 at 20:28:19 UTC, FG wrote:
I suppose this:
immutable long DIM = 1024L*1024L *128L;
immutable(double)[] signal = new double[DIM+1];
static this() {
for (long i=0L; i< DIM+1; i++) {
signal[i] = (i+DIM)%7 + (i+DIM+1)%5;
Sparsh Mittal:
Thanks. However, rdmd gives error on this line:
temp1.d(12): Error: no identifier for declarator immutable(i)
Probably v.2.062 of the D compiler is enough to not see that
error.
Bye,
bearophile
I realized that access to "temp" causes bottleneck. On defining
it inside for loop, it become local and then there is speedup.
Defining it outside makes it shared, which slows the program.
Removing immutable word solves the problem. Thanks.
On Friday, 1 March 2013 at 20:28:19 UTC, FG wrote:
I suppose this:
immutable long DIM = 1024L*1024L *128L;
immutable(double)[] signal = new double[DIM+1];
static this() {
for (long i=0L; i< DIM+1; i++) {
signal[i] = (i+DIM)%7 + (i+DIM+1)%5;
}
}
void main()
{ ... }
Thanks. This
foreach (immutable i; 0 .. DIM + 1) {
Thanks. However, rdmd gives error on this line:
temp1.d(12): Error: no identifier for declarator immutable(i)
Sparsh Mittal:
So, is there a way, an array can be made immutable and still
initialized? Thanks a lot for your time.
There are various ways to do it. One of the safest way to do it
is to create a mutable array inside a strongly pure function, and
then when you return it assign it to immutabl
I suppose this:
immutable long DIM = 1024L*1024L *128L;
immutable(double)[] signal = new double[DIM+1];
static this() {
for (long i=0L; i< DIM+1; i++) {
signal[i] = (i+DIM)%7 + (i+DIM+1)%5;
}
}
void main()
{ ... }
Array is really big!
import std.stdio;
import std.datetime;
import std.parallelism;
import std.range;
//int numberOfWorkers = 2; //for parallel;
double my_abs(double n) { return n > 0 ? n : -n; }
immutable long DIM = 1024L*1024L *128L;
void main()
{
double[] signal = new double[DIM+1];
d
On Friday, 1 March 2013 at 20:05:41 UTC, Sparsh Mittal wrote:
I am making a program which accesses 1D array using for loop
and then I am parallelizing this with foreach, TaskPool and
parallel.
The array does not need to change, once initialized. However,
the parallel version takes more time t
I am making a program which accesses 1D array using for loop and
then I am parallelizing this with foreach, TaskPool and parallel.
The array does not need to change, once initialized. However, the
parallel version takes more time than serial version, which I
think may be because compiler is tr
11 matches
Mail list logo