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


C++ Chrono::stopChrono方法代码示例

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


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

示例1: main

int main(int argc, char** argv) {
    Chrono ch;
    Timer tm;
    ch.startChrono();
    fstream logfile;
    logfile.open("results_knapsack.txt", ios::out);
    //remember the limit of the 4gb allocated space
    int dim[] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
    int local_threads[] = {0, 64, 128, 256, 512, 1024};


    for (int k = 5; k < sizeof (local_threads) / sizeof (int); k++) {//local_threads
        for (int j = 9; j < sizeof (dim) / sizeof (int); j++) {

            TestData* test = new TestData(dim[j]);
            Knapsack *ksack = new Knapsack(*test);

            //1.Query the host system for OpenCL platform info
            ksack->queryOclPlatformInfo(&logfile);
            //2. Query the host for OpenCL devices
            ksack->queryOclDevice(&logfile);

            for (int i = 0; i < ksack->getNumDevices(); i++) {

                ksack->queryOclDeviceInfo(i, &logfile);
                //3. Create a context and a queue to associate the OpenCL devices.
                ksack->createContextQueue(i, &logfile);
                //4. Create programs that will run on one or more associated devices.
                ksack->createProgramBuild(i, &logfile);
                //5. Create memory objects on the host or on the device.
                //6. Copy memory data to the device as needed. Create memory objects on the host or on the device.
                ksack->createMemObjects(&logfile);
                //7. Create Kernels
                ksack->createKernel();
                //8. Provide arguments for the kernels.
                // ksack.createKernel();
                //9. Submit the kernels to the command queue for execution.
                //10. Copy the results from the device to the host
                //ksack.executeMemObjects();
                
                ksack->executeComputation(i, &logfile, local_threads[k]);
                ksack->printResults(&logfile);

            }
            delete ksack;
            delete test;

        }
    }
    logfile.close();
    //http://stackoverflow.com/questions/14063791/double-free-or-corruption-but-why

    ch.stopChrono();
    tm.stop();
    cout << "CHRONO TIME: " << ch.getTimeChrono() << endl;
    cout << "TIMER TIME: " << tm.getTime();

    return 0;

}
开发者ID:nico-mkhatvari,项目名称:OpenCL,代码行数:60,代码来源:knapsack_main.cpp


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