找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 13|回复: 0

amd app sdk

[复制链接]

32万

主题

0

回帖

96万

积分

超级版主

积分
964681
发表于 2025-3-14 11:14:15 | 显示全部楼层 |阅读模式
软件标签:  amdappsdk   编程工具
amd app sdk是一组高级的软硬件技术。这款软件能够使图形处理器(amdgpu)和系统的x86内核(cpu)共同协作。帮助用户快而高效的完成任务。欢迎选哦的用户来下载使用。
amd app sdk官网介绍
amd app,是amd accelerated parallel processing的缩写。中文译作amd加速并行处理技术。是amd针对旗下图形处理器(gpu)所推出的通用并行计算技术。利用这种技术可以充分发挥amd gpu的并行运算能力,用于对软件进行加速运算或进行大型的科学运算。amd app技术的前身称作ati stream。2010年10月,随着amd radeon hd6800系列显卡的发布,ati品牌正式被amd取代。ati stream技术也随着技术升级并更名为amd app技术。amd app的竞争对手是nvidia cuda。(来自百度百科)




amd最近发布了支持最新的opencl 2.0标准的最新通用计算开发包amd app sdk 3.0。这标志着异构计算发展道路上的一个新的里程碑。opencl 2.0实施了很多amd所倡导的新的异构系统架构。值得注意的是,gpu和cpu设备之间的数据结构指针内存共享的概念可以大大地简化gpu参与加速计算的步骤。比起利用opencl 1.2,gpu设备利用了opencl 2.0排队功能进行计算任务,为计算内核提供了一种更加强悍的编程模型。opencl 1.2的通用地址空间是一个强大的编程优势,但是opencl 2.0 引用了一种新的内存对象,叫pipe,这个在采用fifo机制进行数据采集时起到重要的作用。opencl的这些还有其他优势将会帮助你利用现代异构系统性能的巨大潜力。
amd app sdk安装方法
安装过程,我们一般选择默认路径就行,直接点下一步完成安装。如果选择默认自动安装,那么会自动生成变量

amdappsdkroot=c:program filesamd app sdk3.0-0-beta(32位机)

amdappsdkroot=c:program files(x86)amd app sdk3.0-0-beta(64位机)。

如果不是选择默认安装路径,那么就需要人为修改。

系统环境变量path需要作如下修改,32位机和64位机分别添加

$(amdappsdkroot)inx86,对应的就是c:program filesamd app sdk3.0-0-betainx86

$(amdappsdkroot)inx86_64,对应的就是c:program files(x86)amd app sdk3.0-0-betainx86_64

安装好amdappsdk之后,在命令行下运行clinfo命令,将显示出你支持opencl的硬件信息。
amd app sdk配置
我们先新建一个简单的工程,不妨取名为simpleproject,然后编译连接运行。代码的内容我们先不探讨,在下文中会有详细介绍。

#include <cl/cl.h>

#include <stdio.h>

#define nwitems 512

//a simple memset kernel

const char *source =

"__kernel void memset( __global uint *dst )
"

"{
"

" dst[get_global_id(0)] = get_global_id(0);
"

"}
";

int main(int argc, char ** argv)

{

// 1. get a platform.

cl_platform_id platform;

clgetplatformids( 1, &platform, null );

// 2. find a gpu device.

cl_device_id device;

clgetdeviceids( platform, cl_device_type_gpu,1,&device,null);

// 3. create a context and command queue on that device.

cl_context context = clcreatecontext( null, 1, &device, null, null, null);

cl_command_queue queue = clcreatecommandqueue( context, device, 0, null );

// 4. perform runtime source compilation, and obtain kernel entry point.

cl_program program = clcreateprogramwithsource( context, 1, &source, null, null );

clbuildprogram( program, 1, &device, null, null, null );

cl_kernel kernel = clcreatekernel( program, "memset", null );

// 5. create a data buffer.

cl_mem buffer = clcreatebuffer( context, cl_mem_write_only, nwitems*sizeof(cl_float), null, null);

// 6. launch the kernel. let opencl pick the local work size.

size_t global_work_size = nwitems;

clsetkernelarg(kernel, 0, sizeof(buffer), (void*) &buffer);

clenqueuendrangekernel( queue, kernel, 1, null, &global_work_size, null, 0, null, null);

clfinish( queue );

// 7. look at the results via synchronous buffer map.

cl_uint *ptr;

ptr = (cl_uint *) clenqueuemapbuffer( queue, buffer, cl_true, cl_map_read, 0, nwitems * sizeof(cl_uint), 0, null, null, null );

int i;

for(i=0; i < nwitems; i++)

printf("%d %d
", i, ptr);</p
>
return 0;

}

不出意外的话,编译过不了,有下面的提示。

fatal error c1083: cannot open include file: cl/cl.h: no such file or directory

显然,这是因为工程需要的头文件我们的环境并没有把它包含进来,所以,要做如下配置:

打开项目的property pages,在c/c++ -> general ?->additional include directories 中添加

$(amdappsdkroot)/include;



点击build工程之后,出现了下面错误。这是由于我们并没有把工程需要的连接库文件添加进来的问题。需要作如下配置。

1>simpleproject.obj : error lnk2019: unresolved external symbol _clgetplatformids@12 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clgetdeviceids@24 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clcreatecontext@24 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clcreatebuffer@24 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clcreateprogramwithsource@20 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clbuildprogram@24 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clcreatekernel@12 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clsetkernelarg@16 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clfinish@4 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clenqueuemapbuffer@44 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clenqueuendrangekernel@36 referenced in function _main

1>simpleproject.obj : error lnk2019: unresolved external symbol _clcreatecommandqueue@20 referenced in function _main

打开项目的property pages,在linker -> general ?->additional library directories 中添加

$(amdappsdkroot)libx86;

在linker -> input ?->additional dependencies中选择edit,然后添加

opencl.lib

inherited values中默认的值应该为:

kernel32.lib

user32.lib

gdi32.lib

winspool.lib

comdlg32.lib

advapi32.lib

shell32.lib

ole32.lib

oleaut32.lib

uuid.lib

odbc32.lib

odbccp32.lib




程序运行成功。至此,amd app sdk 3.0的下载安装和配置都已经完成了,不明白之处请参阅手册。


aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|ziyuan80.com

GMT+8, 2025-8-18 00:53 , Processed in 0.076993 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表