当前位置: 首页 > news >正文

南宁 网站建设百度怎么建设网站

南宁 网站建设,百度怎么建设网站,网站建设策划结构,直播电商的发展趋势为了测试GPU函数的耗时,可以使用 CUDA 提供的计时功能:cudaEventCreate, cudaEventRecord, 和 cudaEventElapsedTime。这些函数可以帮助你测量某个 CUDA 操作(如设置设备)所花费的时间。 一、记录耗时案例 以下是一个示例程序&a…

为了测试GPU函数的耗时,可以使用 CUDA 提供的计时功能:cudaEventCreate, cudaEventRecord, 和 cudaEventElapsedTime。这些函数可以帮助你测量某个 CUDA 操作(如设置设备)所花费的时间。

一、记录耗时案例

以下是一个示例程序,它测量调用 cudaSetDevice 所花费的时间:

#include <iostream>
#include <vector>
#include <cuda_runtime.h>__global__ void dummyKernel() {// Dummy kernel to ensure CUDA context is initialized
}int main() {// CUDA device IDsint device1 = 0;int numIterations = 10; // Number of times to call cudaSetDevice// Create CUDA eventscudaEvent_t start, stop;cudaEventCreate(&start);cudaEventCreate(&stop);// Vector to store elapsed timesstd::vector<float> elapsedTimes(numIterations);// Set initial device (optional, but ensures a known starting state)cudaSetDevice(device1);// Measure time for multiple cudaSetDevice callsfor (int i = 0; i < numIterations; ++i) {// Record the start eventcudaEventRecord(start, 0);// Set the device (this is the operation we are timing)cudaSetDevice(device1);// Record the stop eventcudaEventRecord(stop, 0);// Measure the elapsed time between the start and stop eventscudaEventElapsedTime(&elapsedTimes[i], start, stop);// Output resultsstd::cout << "Number of iterations: i " << i << std::endl;std::cout << " time to set device " << device1 << ": " << elapsedTimes[i] << " ms" << std::endl;}// Calculate statistics (e.g., average time)float totalTime = 0.0f;for (float time : elapsedTimes) {totalTime += time;}float averageTime = totalTime / numIterations;// Output resultsstd::cout << "Number of iterations: " << numIterations << std::endl;std::cout << "Average time to set device " << device1 << ": " << averageTime << " ms" << std::endl;// Optionally, run a dummy kernel to ensure CUDA is initialized and readydummyKernel<<<1, 1>>>();cudaDeviceSynchronize();// Clean upcudaEventDestroy(start);cudaEventDestroy(stop);return 0;
}

二、编译和运行

         2.1 编译: 使用 nvcc 编译这个 CUDA 程序。(上面程序文件铭为test_cudaSetDevice_multiple.cu)

nvcc -o test_cudaSetDevice_multiple test_cudaSetDevice_multiple.cu

        2.2 运行: ,然后运行生成的可执行文件。

./test_cudaSetDevice_multiple

哈哈哈,就得到运行结果啦! 

http://www.yayakq.cn/news/830335/

相关文章:

  • 网站优化推广方案金华高端网站建设公司
  • 太仓公司做网站淮南建设局网站备案
  • 查询企业年报的网站企业需求发布平台
  • 禹城市建设局网站优化网站链接的方法
  • 网站开发语言php5.1深圳建设厅网站官网
  • 上海闵行网站制作公司上海产品网站建设
  • 东莞企业网站建设设计中信建设有限责任公司是国企吗
  • 八年级上册信息书怎么做网站中小企业建设网站策略
  • 网站做付费推广都需要问什么wordpress主题站
  • 做网站公司的年终总结彩票娱乐网站建设开发
  • 富德生命人寿保险公司官方网站wordpress卡片阴影
  • 做网站公司哪家公司好佛山新网站建设代理商
  • 电子商务网站建设考试wordpress恢复页面
  • 网站建设玖金手指排名14外发加工费计入什么科目
  • 从零开始建网站手机网站首页
  • 村级网站建设 不断增强如何做互联网网站
  • 哈尔滨专业建网站方案网站常州建设
  • 鼓楼做网站价格深圳南山企业网站建设报价
  • 湖北手机网站建设免费不收费的app
  • 网站备案资料申请wordpress 修改网页
  • 专业微网站建设公司哪家好长沙移动网站建设
  • 梅州市工程建设交易中心网站wordpress自带的404
  • 企业网站建设的误区主要有石家庄新闻最新
  • 重生做门户网站的小说unity制作app教程
  • 网站定制哪个好东莞网络营销外包
  • 广州网站建设系统开发网站开发淄博
  • 做微课的网站河南广宇建设集团有限公司网站
  • 锦州网站建设锦州网站参数设定
  • 网站维护什么情况网站备案证书放到哪里
  • 免费php外贸网站模板怎么搭建一个简单的网站