当前位置: 首页>>代码示例>>C++>>正文


C++ ProgressBar::addItersDone方法代码示例

本文整理汇总了C++中ProgressBar::addItersDone方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgressBar::addItersDone方法的具体用法?C++ ProgressBar::addItersDone怎么用?C++ ProgressBar::addItersDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProgressBar的用法示例。


在下文中一共展示了ProgressBar::addItersDone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RunTest

void RunTest(ResultDatabase &resultDB, const int npasses, const int verbose,
        const int noPB, const float repeatF, ProgressBar &pb, 
        const char* precision, const int micdev)
{
    char sizeStr[128];
    static __declspec(target(mic)) T *hostMem;

    int realRepeats = (int)round(repeatF*20);
    if (realRepeats < 2) realRepeats = 2;

    // Allocate host memory
    int halfNumFloats = 1024*1024;
    int numFloats = 2*halfNumFloats;
    hostMem = (T*)_mm_malloc(sizeof(T)*numFloats,64);

    sprintf (sizeStr, "Size:%07d", numFloats);
    float t = 0.0f;
    double TH;
    double flopCount;
    double gflop;

    for (int pass=0 ; pass<npasses ; ++pass)
    {
        ////////// Add1 //////////
        InitData<T>(hostMem,numFloats);
        #pragma offload target(mic:micdev) in(hostMem:length(numFloats) free_if(0))
        {}
        TH = curr_second();
        #pragma offload target(mic:micdev) in(numFloats,realRepeats) nocopy(hostMem)
        {
            Add1_MIC<T>(numFloats,hostMem, realRepeats, 10.0);
        }
        t = curr_second()-TH;
        flopCount = (double)numFloats * realRepeats * omp_get_num_threads();
        gflop = flopCount / (double)(t*1e9);
        resultDB.AddResult(string("Add1")+precision, sizeStr, "GFLOPS", gflop);
        
        #pragma offload target(mic:micdev) out(hostMem:length(numFloats) alloc_if(0))
        {}
        CheckResults<T>(hostMem,numFloats);
        pb.addItersDone();
        if (!verbose && !noPB)pb.Show(stdout);

        ////////// Add2 //////////
        InitData<T>(hostMem,numFloats);
        #pragma offload target(mic:micdev) in(hostMem:length(numFloats) free_if(0))
        {}
        TH = curr_second();
        #pragma offload target(mic:micdev) in(numFloats,realRepeats) nocopy(hostMem)
        {
            Add2_MIC<T>(numFloats,hostMem, realRepeats, 10.0);
        }
        t = curr_second()-TH;
        flopCount = (double)numFloats * realRepeats * 120 * 2;
        gflop = flopCount / (double)(t*1e9);
        resultDB.AddResult(string("Add2")+precision, sizeStr, "GFLOPS", gflop);
        #pragma offload target(mic:micdev) out(hostMem:length(numFloats) alloc_if(0))
        {}
        CheckResults<T>(hostMem,numFloats);
        pb.addItersDone();
        if (!verbose && !noPB)pb.Show(stdout);

        ////////// Add4 //////////
        InitData<T>(hostMem,numFloats);
        #pragma offload target(mic:micdev) in(hostMem:length(numFloats) free_if(0))
        {}
        TH = curr_second();
        #pragma offload target(mic:micdev) in(numFloats,realRepeats) nocopy(hostMem)
        {
            Add4_MIC<T>(numFloats,hostMem, realRepeats, 10.0);
        }
        t = curr_second()-TH;
        flopCount = (double)numFloats * realRepeats * 60 * 4;
        gflop = flopCount / (double)(t*1e9);
        resultDB.AddResult(string("Add4")+precision, sizeStr, "GFLOPS", gflop);
        #pragma offload target(mic:micdev) out(hostMem:length(numFloats) alloc_if(0))
        {}
        CheckResults<T>(hostMem,numFloats);
        pb.addItersDone();
        if (!verbose && !noPB)pb.Show(stdout);

        ////////// Add8 //////////
        InitData<T>(hostMem,numFloats);
        #pragma offload target(mic:micdev) in(hostMem:length(numFloats) free_if(0))
        {}
        TH = curr_second();
        #pragma offload target(mic:micdev) in(numFloats,realRepeats) nocopy(hostMem)
        {
            Add8_MIC<T>(numFloats,hostMem, realRepeats, 10.0);
        }
        t = curr_second()-TH;
        flopCount = (double)numFloats * realRepeats * 80 * 3;
        gflop = flopCount / (double)(t*1e9);
        resultDB.AddResult(string("Add8")+precision, sizeStr, "GFLOPS", gflop);
        #pragma offload target(mic:micdev) out(hostMem:length(numFloats) alloc_if(0))
        {}
        CheckResults<T>(hostMem,numFloats);
        pb.addItersDone();
        if (!verbose && !noPB)pb.Show(stdout);

//.........这里部分代码省略.........
开发者ID:optimus-prime,项目名称:shoc-mic,代码行数:101,代码来源:MaxFlops.cpp

示例2: kernelCode


//.........这里部分代码省略.........

             double gflop = flopCount / (double)(evKernel.SubmitEndRuntime());

             sprintf (sizeStr, "Size:%07d", numFloats);
             resultDB.AddResult(string(temp.name)+precision, sizeStr, "GFLOPS", gflop);

             // Zero out the test host memory
             for (int j=0 ; j<numFloats ; ++j)
             {
                 hostMem2[j] = 0.0;
             }

             // Read the result device memory back to the host
             err = clEnqueueReadBuffer(queue, mem1, true, 0,
                                 numFloats*sizeof(T), hostMem2,
                                 0, NULL, NULL);
             CL_CHECK_ERROR(err);
               
             // Check the result -- At a minimum the first half of memory
             // should match the second half exactly
             for (int j=0 ; j<halfNumFloats ; ++j)
             {
                if (hostMem2[j] != hostMem2[numFloats-j-1])
                {
                   cout << "Error; hostMem2[" << j << "]=" << hostMem2[j]
                        << " is different from its twin element hostMem2["
                        << (numFloats-j-1) << "]=" << hostMem2[numFloats-j-1]
                        <<"; stopping check\n";
                   break;
                }
             }
             
             // update progress bar
             pb.addItersDone();
             if (!verbose && !quiet)
                 pb.Show(stdout);
          }
       }

       err = clReleaseKernel (kernel_madd);
       CL_CHECK_ERROR(err);
       err = clReleaseProgram (prog);
       CL_CHECK_ERROR(err);
       err = clReleaseMemObject(mem1);
       CL_CHECK_ERROR(err);

       aIdx += 1;
       
       delete[] hostMem;
       delete[] hostMem2;
    }
 
    // Now, test hand-tuned custom kernels
    
    // 2D - width and height of input
    const int w = 2048, h = 2048;
    const int bytes = w * h * sizeof(T);
    
    // Allocate some device memory
    mem1 = clCreateBuffer(ctx, CL_MEM_READ_WRITE, bytes, NULL, &err);
    CL_CHECK_ERROR(err);
    
    // Get a couple non-zero random numbers
    float val1 = 0, val2 = 0;
    while (val1==0 || val2==0)
    {
开发者ID:ashwinma,项目名称:mpiacc-contention-tests,代码行数:67,代码来源:MaxFlops.cpp


注:本文中的ProgressBar::addItersDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。