ホーム » VC OpenMP » MessageBar クラスと OpenMP

2015年1月
 123
45678910
11121314151617
18192021222324
25262728293031

カテゴリー

アーカイブ

ブログ統計情報

  • 77,416 アクセス



MessageBar クラスと OpenMP

新しい Message クラスを使用して,OpenMP 対応の動作のテスト.
void CTSttBView::OnTestDrawBar2()
{
  Message tmp ;
  ElapseTick et ;
  #define BAR_COUNT_2 1000000
  #ifdef _OPENMP
    #pragma omp parallel for
  #endif
  for (int i=0 ; i<100 ; i++) {
    Message bar ;
    bar.SetBar (_T(“Test Message 1 M * 100”),BAR_COUNT_2,RGB(0,255,0)) ;
    for (int index=0 ; index<BAR_COUNT_2 ; index++) {
      bar.SetBarInc() ;
      }
    }
  DWORD elapseT = et.GetElapse() ;
  CString str ; str.Format(_T(“%.2f 秒”),elapseT/1000.) ;
  AfxMessageBox(str) ;
  }
1 億回 SetBarInc を呼出していて,10 秒程度だったのが,#pragma omp parallel for で 20 秒程度になってしまった.


inline bool MessageBase::SetBarInc (void)
{
  if (GetBarMax() == 0) { return false ; }
  if (GetBarCount() < GetBarMax()) { B_Counter++ ; }
  else { B_Counter = 0 ; } // reset
  IncCounterR() ;
  {
    long lastPos = long(100*(GetBarCount()-1)/GetBarMax()) ;
    long new_Pos = long(100*(GetBarCount()-0)/GetBarMax()) ;
    if (lastPos == new_Pos) { return true ; }
    }
  #ifdef _WINDOWS
  #ifdef _MFC_VER
  #ifdef _OPENMP
    if (AfxGetMainWnd() == NULL) { return false ; }
  #endif
  #endif
  #endif
  return SetBarCount(B_Counter) ;
  }
AfxGetMainWnd() を呼出す回数を減らすことにより,3 秒程度に.

Is this 投稿 useful? Useful Useless 0 of 0 people say this 投稿 is useful.

コメントする

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

%d人のブロガーが「いいね」をつけました。