cubla sample-code
cublasSscal
//Example 1. Application Using C and CUBLAS: 1-based indexing #include <stdlib.h>
#include <math.h>
#include <cuda_runtime.h>
#include "cublas_v2.h"
#include <stdio.h>
#define M 6
#define N 5
#define IDX2F(i,j,ld) ((((j)-1)*(ld))+((i)-1))
static __inline__ void modify (cublasHandle_t handle, float*m, int ldm, int
n, int p, int q, float alpha, float beta){
cublasSscal (handle, n-p+, &alpha, &m[IDX2F(p,q,ldm)], ldm);
cublasSscal (handle, ldm-p+, &beta, &m[IDX2F(p,q,ldm)], );
}
int main (void){
cudaError_t cudaStat;
cublasStatus_t stat;
cublasHandle_t handle;
int i, j;
float* devPtrA;
float* a = ;
a = (float*)malloc (M * N * sizeof(*a));
if(!a) {
printf("host memory allocation failed");
return EXIT_FAILURE;
}
for(j = ; j <= N; j++) {
for(i = ; i <= M; i++) {
a[IDX2F(i,j,M)] = (float)((i-) * M + j);
printf("%7.0f",a[IDX2F(i,j,M)]);
}printf("\n");
}printf("\n");
cudaStat = cudaMalloc ((void**)&devPtrA, M*N*sizeof(*a));
if(cudaStat != cudaSuccess) {
printf ("device memory allocation failed");
return EXIT_FAILURE;
}
stat = cublasCreate(&handle);
if(stat != CUBLAS_STATUS_SUCCESS) {
printf ("CUBLAS initialization failed\n");
return EXIT_FAILURE;
}
stat = cublasSetMatrix (M, N, sizeof(*a), a, M, devPtrA, M);
if(stat != CUBLAS_STATUS_SUCCESS) {
printf ("data download failed");
cudaFree (devPtrA);
cublasDestroy(handle);
return EXIT_FAILURE;
}
modify (handle, devPtrA, M, N, , , 16.0f, 12.0f);
stat = cublasGetMatrix (M, N, sizeof(*a), devPtrA, M, a, M);
if(stat != CUBLAS_STATUS_SUCCESS) {
printf("data upload failed");
cudaFree (devPtrA);
cublasDestroy(handle);
return EXIT_FAILURE;
}
cudaFree (devPtrA);
cublasDestroy(handle);
for(j = ; j <= N; j++) {
for(i = ; i <= M; i++) {
printf ("%7.0f", a[IDX2F(i,j,M)]);
}
printf ("\n");
}
free(a);
return EXIT_SUCCESS;
}

cubla sample-code的更多相关文章
- android studio2.2 的Find Sample Code点击没有反应
1 . 出现的问题描述: 右键点击Find Sample Code后半天没有反应,然后提示 Samples are currently unavailable for :{**** ...
- 如何将经纬度利用Google Map API显示C# VS2005 Sample Code
原文 如何将经纬度利用Google Map API显示C# VS2005 Sample Code 日前写了一篇如何用GPS抓取目前所在,并回传至资料库储存,这篇将会利用这些回报的资料,将它显示在地图上 ...
- IOS开发苹果官方Sample Code及下载地址
IOS开发苹果官方Sample Code及下载地址 在线浏览地址:https://developer.apple.com/library/ios/navigation/#section=Resourc ...
- OAF Sample Code(转)
原文地址: OAF Sample Code
- Sample Code之Web scene-slides
这是我的第一篇随笔,在开始正文前说几句. 这个系列会记录我学习Arcgis js API 4.10的全过程,希望能对自己也对其他有需要的人有帮助.很多时候上网看一些大神的帖子会感到一头雾水,一是自己水 ...
- sample code java pom.xml
pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="htt ...
- sqoop sample code
本文使用的数据库是mysql的sample database employees. download url:https://launchpad.net/test-db/employees-db-1/ ...
- Sample Code for Qp_preq_pub.Price_request Api to Simulate an Ask for Promotion Modifier
DECLARE p_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE; p_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE; p_line_attr_tbl ...
- 虹软人脸识别Android Sample Code
AFR_FSDKInterface engine = new AFR_FSDKEngine(); //用来存放提取到的人脸信息, face_1 是注册的人脸,face_2 是要识别的人脸 AFR_FS ...
- Apache Flink Training and sample code
http://training.data-artisans.com/ https://github.com/dataArtisans/blog-post-code-samples https://gi ...
随机推荐
- 《Publish or Perish》——从某种角度来说,我们也算和世界同步了呢。
- PAT-乙级-1004. 成绩排名 (20)
1004. 成绩排名 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 读入n名学生的姓名.学号.成绩,分 ...
- WCF 绑定的选择
选自<WCF服务编程中文版> 第一章 WCF基础 绑定服务之间的通信方式是多种多样的,有多种可能的通信模式.包括:同步的请求/ 应答(Request/Reply)消息,或者异步的“即发即弃 ...
- C++: 单例模式和缺陷
C++: 单例模式和缺陷 实现一个单例模式 1 class Singleton { 2 private: 3 Singleton() { cout << " ...
- 用MT.exe将exe中的manifest文件提取出来和将manifest文件放入exe中
前一种方法是将manifest文件放入exe中,但是要记得需要在工程中设置 这样的话exe中就不存在manifest了,在debug目录下就会看到相应的manifest文件.后者是将exe中的man ...
- 修改tomcat的默认编码
在tomcat的安装路径下查找conf文件下的server.xml文件,修改此文件即可,修改内容如下: <Connector port="8080" protocol=&qu ...
- 64位ubuntu安装WPS
http://jingyan.baidu.com/article/d3b74d64afd96f1f77e609a3.html http://sixipiaoyang.blog.163.com/blog ...
- Android:requestWindowFeature应用程序窗体显示状态操作
注意requestWindowFeature必须在 setContentView()之前调用. 1.DEFAULT_FEATURES:系统默认状态,一般不需要指定 2.FEATURE_CONTEXT_ ...
- 性能优化工具 MVC Mini Profiler
性能优化工具 MVC Mini Profiler MVC MiniProfiler是Stack Overflow团队设计的一款对ASP.NET MVC.WebForm 以及WCF 的性能分析的小程 ...
- node.js模块之fs文件系统
fs 模块是文件操作的封装,它提供了文件的读取.写入.更名.删除.遍历目录.链接等 POSIX 文件系统操作.与其他模块不同的是,fs 模块中所有的操作都提供了异步的和同步的两个版本, 例如读取文件内 ...