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

极简wordpress主题seo网站优化网站编辑招聘

极简wordpress主题,seo网站优化网站编辑招聘,东莞做网站公司哪家比较好,如何给网站做外部优化在多GPU运行应用程序时,需要正确设计GPU之间的通信,GPU间数据传输的效率取决于GPU是如何连接在一个节点上并跨集群的 在多GPU系统里有两种连接方式 多GPU通过单个节点连接到PCIe总线上 多GPU连接到集群中的网络交换机上 /* * 本示例演示了如何使用 Open…

在多GPU运行应用程序时,需要正确设计GPU之间的通信,GPU间数据传输的效率取决于GPU是如何连接在一个节点上并跨集群的
在多GPU系统里有两种连接方式
多GPU通过单个节点连接到PCIe总线上
多GPU连接到集群中的网络交换机上

/*
* 本示例演示了如何使用 OpenMP API 为多个 GPU 编写应用程序在 CPU 端使用 OpenMP 进行线程处理的多 GPU 示例, 需要支持 OpenMP 2.0 的编译器*/#include <omp.h>
#include <stdio.h>  // 使用 stdio 函数,因为 C++ 流不一定是线程安全的
#include <helper_cuda.h>using namespace std;//一个简单的内核,只需将每个数组元素递增 b
__global__ void kernelAddConstant(int *g_a, const int b)
{int idx = blockIdx.x * blockDim.x + threadIdx.x;g_a[idx] += b;
}
// 一个谓词,用于检查每个数组元素是否被设置为其索引加上 b
int correctResult(int *data, const int n, const int b)
{for (int i = 0; i < n; i++)if (data[i] != i + b)return 0;return 1;
}
int main(int argc, char *argv[])
{int num_gpus = 0;   // CUDA GPU 数量printf("%s Starting...\n\n", argv[0]);/// 确定支持 CUDA 的 GPU 数量//cudaGetDeviceCount(&num_gpus);if (num_gpus < 1){printf("no CUDA capable devices were detected\n");return 1;}/// 显示 CPU 和 GPU 配置//printf("number of host CPUs:\t%d\n", omp_get_num_procs());printf("number of CUDA devices:\t%d\n", num_gpus);for (int i = 0; i < num_gpus; i++){cudaDeviceProp dprop;cudaGetDeviceProperties(&dprop, i);printf("   %d: %s\n", i, dprop.name);}printf("---------------------------\n");/// initialize data//unsigned int n = num_gpus * 8192;unsigned int nbytes = n * sizeof(int);int *a = 0;     // 指向 CPU 上数据的指针int b = 3;      // 数组递增的值a = (int *)malloc(nbytes);if (0 == a){printf("couldn't allocate CPU memory\n");return 1;}for (unsigned int i = 0; i < n; i++)a[i] = i;// 运行与 CUDA 设备数量相同的 CPU 线程//每个 CPU 线程控制不同的设备,处理各自的数据部分。 // 使用的 CPU 线程数量有可能多于 CUDA 设备的数量,在这种情况下,多个 CPU 线程将在同一设备上分配资源并启动内核。// 例如,尝试 omp_set_num_threads(2 * num_gpus); // 请注意,在 "omparallel "作用域内声明的所有变量都是 是每个 CPU 线程的局部变量//omp_set_num_threads(num_gpus);  //创建与 CUDA 设备数量相同的 CPU 线程//omp_set_num_threads(2*num_gpus);// 创建的 CPU 线程数量是 CUDA 设备数量的两倍#pragma omp parallel{unsigned int cpu_thread_id = omp_get_thread_num();unsigned int num_cpu_threads = omp_get_num_threads();// 设置并检查该 CPU 线程的 CUDA 设备int gpu_id = -1;checkCudaErrors(cudaSetDevice(cpu_thread_id % num_gpus));   // "% num_gpus "允许 CPU 线程数量多于 GPU 设备数量checkCudaErrors(cudaGetDevice(&gpu_id));printf("CPU thread %d (of %d) uses CUDA device %d\n", cpu_thread_id, num_cpu_threads, gpu_id);int *d_a = 0;   // 指向与该 CPU 线程相关联的设备上内存的指针int *sub_a = a + cpu_thread_id * n / num_cpu_threads;   // 指向该 CPU 线程数据部分的指针unsigned int nbytes_per_kernel = nbytes / num_cpu_threads;dim3 gpu_threads(128);  // 128 threads per blockdim3 gpu_blocks(n / (gpu_threads.x * num_cpu_threads));checkCudaErrors(cudaMalloc((void **)&d_a, nbytes_per_kernel));checkCudaErrors(cudaMemset(d_a, 0, nbytes_per_kernel));checkCudaErrors(cudaMemcpy(d_a, sub_a, nbytes_per_kernel, cudaMemcpyHostToDevice));kernelAddConstant<<<gpu_blocks, gpu_threads>>>(d_a, b);checkCudaErrors(cudaMemcpy(sub_a, d_a, nbytes_per_kernel, cudaMemcpyDeviceToHost));checkCudaErrors(cudaFree(d_a));}printf("---------------------------\n");if (cudaSuccess != cudaGetLastError())printf("%s\n", cudaGetErrorString(cudaGetLastError()));// check the result//bool bResult = correctResult(a, n, b);if (a)free(a); // free CPU memoryexit(bResult ? EXIT_SUCCESS : EXIT_FAILURE);
}

在这里插入图片描述

http://www.shuangfujiaoyu.com/news/44966.html

相关文章:

  • 武汉做网站seo广州企业推广
  • 通过网站做跳板公司网站免费自建
  • 云南省建设教育协会网站设计网站模板
  • 企业网站建设大概费用百度惠生活推广怎么收费
  • 菏泽做企业网站无锡营销型网站建站
  • css做网站怎么添加子页怎么网上宣传自己的产品
  • 旅游网站怎么做的宁波如何做seo排名优化
  • 网站点击率查询百度搜索入口网址
  • 陕西住房与城乡建设厅网站百度中心
  • 怎样做微网站怎么推广网站
  • 葫芦岛住房和城乡建设厅网站百度旧版本
  • 阿里云网站建设二级不死域名购买
  • 本地局域网搭建wordpress福州seo建站
  • 徐州网站开发服务大数据平台
  • 日本做h动漫电影网站有哪些做网站推广公司
  • 网站搜索系统广告营销推广
  • 最好用的企业网站cms站长工具查询域名信息
  • 内网穿透做网站上海今天发生的重大新闻
  • 做一个门户网站要多少钱永久免费客服系统
  • 微信订阅号不认证可以做网站吗优就业seo课程学多久
  • 建设银行佛山分行网站世界比分榜
  • 香港公司怎么做网站深圳网络推广系统
  • 龙岗 网站建设哪全网营销软件
  • 临沧高端网站建设好用的百度网盘搜索引擎
  • 深圳信用网官网北京seo公司wyhseo
  • 山东地产网站建设我想开个网站平台怎么开呢
  • 小型企业网站开发价格网络运营和网络营销的区别
  • google网站管理员中心手机如何制作网站教程
  • php可以做视频网站吗百度推广客服电话
  • 山西专业网站建设大全宁波seo优化