本文主要是介绍FortranCL错误:forrtl: severe (157): Program Exception - access violation,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
FortranCL错误:forrtl: severe (157): Program Exception - access violation
!错误代码段:double precision :: ax(nx,ny)......colume_in_bytes = int(nx, 8)*8_8row_in_bytes = int(ny, 8)*8_8......cl_ax = clCreateBuffer(context, CL_MEM_READ_ONLY, colume_in_bytes*row_in_bytes, ierr)call clEnqueueWriteBuffer(command_queue, cl_ax, cl_bool(.true.),0_8, colume_in_bytes*row_in_bytes, ax(1,1), ierr)
错误原因: “clEnqueueWriteBuffer”该句内存访问冲突,cl_ax被定义为colume_in_bytes*row_in_bytes 即nx*ny *64,而ax只有nx *ny *8大小,假设nx=ny=2,意味着设备需要从 主机端4 *8个字节中读取4 *64个字节存储,越界产生冲突
更正方法:
bytes = int(ny, 8) \* int(nx, 8)*8_8 call clEnqueueWriteBuffer(command_queue, cl_ax, cl_bool(.true.),0_8, bytes, ax(1,1), ierr)
注意:double precision 与real(8) 含义相同,代表双精度,一般情况下在计算机中占8个字节,_8含义为一个字节占8bit
这篇关于FortranCL错误:forrtl: severe (157): Program Exception - access violation的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!