From: Daniel Berger Date: 2007-03-12T05:10:05+09:00 Subject: Trying to make Array#collect massively parallel with OpenMP Hi all, Windows XP Home VC++ 8 (free edition) Just for kicks I tried creating a parallel Array#collect method, which I called Array#acollect (asynch. collect). I added the following C code to array.c, rebuilt and reinstalled, but it doesn't seem to be any faster. Could this be an issue with my compiler? Or a Windows thing? static VALUE rb_ary_acollect(VALUE ary){ long i; VALUE collect; if (!rb_block_given_p()) return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr); collect = rb_ary_new2(RARRAY(ary)->len); #pragma omp parallel for for (i = 0; i < RARRAY(ary)->len; i++) rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i])); return collect; } rb_define_method(rb_cArray, "acollect", rb_ary_acollect, 0); # bench_collect.rb require "benchmark" MAX = 4000 array = [] MAX.times{ |n| array[n] = 2 * n } # No significant difference (?) Benchmark.bm(30) do |x| x.report("Array#collect"){ MAX.times{ array.collect{ |e| e += 4 } } } x.report("Array#acollect"){ MAX.times{ array.acollect{ |e| e += 4 } } } end Ideas? Thanks, Dan