![Radeon Pro Solid State Graphics Скачать руководство пользователя страница 10](http://html.mh-extra.com/html/radeon/pro-solid-state-graphics/pro-solid-state-graphics_api-user-manual_776864010.webp)
Rev. 1.01
10
5
AMD Code Sample for OpenCL
// Create file.
cl_int
clStatus =
CL_SUCCESS
;
cl_file_amd
clSsgFile =
clCreateSsgFileObjectAMD
(m_clContext,
CL_FILE_READ_ONLY_AMD,
FILE_NAME, &clStatus);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Error: Unable to create file handle."
<< std::endl;
return
;
}
// Get the file-size information.
size_t
retSize = 0;
LARGE_INTEGER
SsgFileSize;
clStatus =
clGetSsgFileObjectInfoAMD
(clSsgFile,
CL_FILE_SIZE_AMD
,
sizeof
(SsgFileSize), &SsgFileSize, &retSize);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Error: Unable to retrieve file size."
<< std::endl;
return
;
}
if (retSize !=
sizeof
(SsgFileSize)) {
s
td::cout
<<
"Error: Invalid file size info returned."
<< std::endl;
return
;
}
// Get the sector-size information.
// Allocated buffer must align with the sector size for best performance.
cl_uint
sectorSize = 0;
clStatus =
clGetSsgFileObjectInfoAMD
(clSsgFile,
CL_FILE_BLOCK_SIZE_AMD
,
sizeof
(sectorSize), §orSize, &retSize);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Error: Unable to retrieve file size."
<< std::endl;
return
;
}
if (retSize !=
sizeof
(sectorSize)) {
s
td::cout
<<
"Error: Invalid sector size info returned."
<< std::endl;
return
;
}
// Create buffer.
cl_mem
clBuffer =
clCreateBuffer
(m_clContext,
CL_MEM_
USE_PERSISTENT_MEM_AMD,
DATA_SIZE_IN_BYTES,
nullptr
, &clStatus);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Error: Unable to create buffer."
<< std::endl;
return
;
}
// Read information from the file; BUFF_OFFSET, SIZE_TO_READ and FILE_OFFSET must
// align with the sector size.
clStatus =
clEnqueueReadSsgFileAMD
(m_clCommandQueue, clBuffer,
CL_TRUE
, BUFF_OFFSET,
SIZE_TO_READ, clSsgFile, FILE_OFFSET, 0, NULL, NULL);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Error: Data transfer failed."
<< std::endl;
}
// Release the file when you’re done with it.
clStatus =
clReleaseSsgFileObjectAMD(
clSsgFile);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Warning: Unable to release file."
<< std::endl;
}
// Release the buffer when you’re done with it.
clStatus =
clReleaseBuffer(
clBuffer);
if (clStatus !=
CL_SUCCESS
) {
s
td::cout
<<
"Warning: Unable to release buffer."
<< std::endl;
}
Содержание Pro Solid State Graphics
Страница 1: ...Solid State Graphics SSG API User Manual ...