全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Gauss专版
3075 0
2008-06-24

http://www.aptech.com/

http://www.econotron.com/gaussx/readme2.htm

Example of Threaded Code
in GAUSS™ 9.0

Below is some sample code written first as a single thread, then divided into four threads.

// Procedure

proc mloop(x,N,its,pos);
  local m;

  m = 0;
  for i(1,its,1);
    m = m + moment(x[pos:pos+N-1,.],0);
    pos = pos + N;
  endfor;

  retp(m);
endp;

N = 4000;
x = rndn(N*N,4);

// Single-Threaded Calculation

mlp = mloop( x, N, N, 1 );

// Multi-Threaded Calculation (split into four threads for a quad-core machine)

R = rows(x)/4;
ThreadStat m1 = mloop(x, N, N/4, 1    );
ThreadStat m2 = mloop(x, N, N/4, 1+R  );
ThreadStat m3 = mloop(x, N, N/4, 1+R*2);
ThreadStat m4 = mloop(x, N, N/4, 1+R*3);
ThreadJoin;
mtmlp = m1 + m2 + m3 + m4;


Running time trials with these calculations on a quad-core machine, the multi-threaded calculation averaged 3.3 times faster than the single-threaded call!

Additional examples of how to incorporate threading into programs will be added periodically, so check back here for new examples.

  • GAUSS 9.0
  • GAUSS 9.0 Update Flyer [112k]GAUSS 9.0 Update Flyer
  • 二维码

    扫码加我 拉你入群

    请注明:姓名-公司-职位

    以便审核进群资格,未注明则拒绝

    相关推荐
    栏目导航
    热门文章
    推荐文章

    说点什么

    分享

    扫码加好友,拉您进群
    各岗位、行业、专业交流群