Merge branch 'amd-master-next' into amd-npi-next
Change-Id: I3b91e45da7cb38c2a2c6d8675e7651de754764ec
This commit is contained in:
+10
-15
@@ -373,18 +373,18 @@ if(HIP_PLATFORM STREQUAL "hcc")
|
||||
set_property ( TARGET hip_hcc PROPERTY VERSION "${HIP_LIB_VERSION_STRING}" )
|
||||
set_property ( TARGET hip_hcc PROPERTY SOVERSION "${HIP_LIB_VERSION_MAJOR}" )
|
||||
|
||||
if(HIP_COMPILER STREQUAL "hcc")
|
||||
target_link_libraries(hip_hcc PRIVATE hc_am)
|
||||
target_link_libraries(hip_hcc_static PRIVATE hc_am)
|
||||
target_link_libraries(hip_hcc PRIVATE hc_am)
|
||||
target_link_libraries(hip_hcc_static PRIVATE hc_am)
|
||||
|
||||
add_library(hiprtc SHARED src/hiprtc.cpp src/code_object_bundle.cpp)
|
||||
set_property ( TARGET hiprtc PROPERTY VERSION "${HIP_LIB_VERSION_STRING}" )
|
||||
set_property ( TARGET hiprtc PROPERTY SOVERSION "${HIP_LIB_VERSION_MAJOR}" )
|
||||
add_library(hiprtc SHARED src/hiprtc.cpp src/code_object_bundle.cpp)
|
||||
target_compile_options(hiprtc PRIVATE -DDISABLE_REDUCED_GPU_BLOB_COPY)
|
||||
set_property ( TARGET hiprtc PROPERTY VERSION "${HIP_LIB_VERSION_STRING}" )
|
||||
set_property ( TARGET hiprtc PROPERTY SOVERSION "${HIP_LIB_VERSION_MAJOR}" )
|
||||
|
||||
target_include_directories(
|
||||
hiprtc SYSTEM
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/include ${HSA_PATH}/include)
|
||||
|
||||
target_include_directories(
|
||||
hiprtc SYSTEM
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/include ${HSA_PATH}/include)
|
||||
endif()
|
||||
set_target_properties(hip_hcc PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
||||
set_target_properties(hip_hcc PROPERTIES VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
@@ -448,12 +448,7 @@ endif()
|
||||
#############################
|
||||
# Install hip_hcc if platform is hcc
|
||||
if(HIP_PLATFORM STREQUAL "hcc")
|
||||
if(HIP_COMPILER STREQUAL "hcc")
|
||||
install(TARGETS hip_hcc_static hip_hcc hiprtc DESTINATION lib)
|
||||
else()
|
||||
install(TARGETS hip_hcc_static hip_hcc DESTINATION lib)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Install .hipInfo
|
||||
|
||||
فروخته شده
+5
-5
@@ -177,7 +177,7 @@ def docker_build_inside_image( def build_image, String inside_args, String platf
|
||||
cd ${build_dir_rel}
|
||||
make install -j\$(nproc)
|
||||
make build_tests -i -j\$(nproc)
|
||||
ctest -E "(hipMultiThreadDevice-pyramid|hipMemoryAllocateCoherentDriver)"
|
||||
ctest --output-on-failure -E "(hipMultiThreadDevice-pyramid|hipMemoryAllocateCoherentDriver)"
|
||||
"""
|
||||
// If unit tests output a junit or xunit file in the future, jenkins can parse that file
|
||||
// to display test results on the dashboard
|
||||
@@ -295,13 +295,13 @@ def docker_upload_dockerhub( String local_org, String image_name, String remote_
|
||||
String build_config = 'Release'
|
||||
String job_name = env.JOB_NAME.toLowerCase( )
|
||||
|
||||
// The following launches 3 builds in parallel: rocm-head, rocm-3.0.x and cuda-10.x
|
||||
parallel rocm_3_0:
|
||||
// The following launches 3 builds in parallel: rocm-head, rocm-3.1.x and cuda-10.x
|
||||
parallel rocm_3_1:
|
||||
{
|
||||
node('hip-rocm')
|
||||
{
|
||||
String hcc_ver = 'rocm-3.0.x'
|
||||
String from_image = 'ci_test_nodes/rocm-3.0.x/ubuntu-16.04:latest'
|
||||
String hcc_ver = 'rocm-3.1.x'
|
||||
String from_image = 'ci_test_nodes/rocm-3.1.x/ubuntu-16.04:latest'
|
||||
String inside_args = '--device=/dev/kfd --device=/dev/dri --group-add=video'
|
||||
|
||||
// Checkout source code, dependencies and version files
|
||||
|
||||
+1003
-636
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
Diff را بارگزاری کن
+45
-49
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
* Copyright (c) 2008-2019 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
@@ -29,11 +29,7 @@
|
||||
#ifndef __OPENCL_CL_EGL_H
|
||||
#define __OPENCL_CL_EGL_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -65,69 +61,69 @@ typedef intptr_t cl_egl_image_properties_khr;
|
||||
#define cl_khr_egl_image 1
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromEGLImageKHR(cl_context /* context */,
|
||||
CLeglDisplayKHR /* egldisplay */,
|
||||
CLeglImageKHR /* eglimage */,
|
||||
cl_mem_flags /* flags */,
|
||||
const cl_egl_image_properties_khr * /* properties */,
|
||||
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clCreateFromEGLImageKHR(cl_context context,
|
||||
CLeglDisplayKHR egldisplay,
|
||||
CLeglImageKHR eglimage,
|
||||
cl_mem_flags flags,
|
||||
const cl_egl_image_properties_khr * properties,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)(
|
||||
cl_context context,
|
||||
CLeglDisplayKHR egldisplay,
|
||||
CLeglImageKHR eglimage,
|
||||
cl_mem_flags flags,
|
||||
const cl_egl_image_properties_khr * properties,
|
||||
cl_int * errcode_ret);
|
||||
cl_context context,
|
||||
CLeglDisplayKHR egldisplay,
|
||||
CLeglImageKHR eglimage,
|
||||
cl_mem_flags flags,
|
||||
const cl_egl_image_properties_khr * properties,
|
||||
cl_int * errcode_ret);
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueAcquireEGLObjectsKHR(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clEnqueueAcquireEGLObjectsKHR(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseEGLObjectsKHR(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clEnqueueReleaseEGLObjectsKHR(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)(
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
|
||||
|
||||
#define cl_khr_egl_event 1
|
||||
|
||||
extern CL_API_ENTRY cl_event CL_API_CALL
|
||||
clCreateEventFromEGLSyncKHR(cl_context /* context */,
|
||||
CLeglSyncKHR /* sync */,
|
||||
CLeglDisplayKHR /* display */,
|
||||
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clCreateEventFromEGLSyncKHR(cl_context context,
|
||||
CLeglSyncKHR sync,
|
||||
CLeglDisplayKHR display,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)(
|
||||
cl_context context,
|
||||
CLeglSyncKHR sync,
|
||||
CLeglDisplayKHR display,
|
||||
cl_int * errcode_ret);
|
||||
cl_context context,
|
||||
CLeglSyncKHR sync,
|
||||
CLeglDisplayKHR display,
|
||||
cl_int * errcode_ret);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+447
-249
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
* Copyright (c) 2008-2019 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
@@ -26,8 +26,6 @@
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
******************************************************************************/
|
||||
|
||||
/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
|
||||
|
||||
/* cl_ext.h contains OpenCL extensions which don't have external */
|
||||
/* (OpenGL, D3D) dependencies. */
|
||||
|
||||
@@ -38,11 +36,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#include <CL/cl.h>
|
||||
|
||||
/* cl_khr_fp64 extension - no extension #define since it has no functions */
|
||||
/* CL_DEVICE_DOUBLE_FP_CONFIG is defined in CL.h for OpenCL >= 120 */
|
||||
|
||||
#if CL_TARGET_OPENCL_VERSION <= 110
|
||||
#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
|
||||
#endif
|
||||
|
||||
/* cl_khr_fp16 extension - no extension #define since it has no functions */
|
||||
@@ -52,12 +52,12 @@ extern "C" {
|
||||
*
|
||||
* Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
|
||||
*
|
||||
* Registers a user callback function that will be called when the memory object is deleted and its resources
|
||||
* freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
|
||||
* stack associated with memobj. The registered user callback functions are called in the reverse order in
|
||||
* which they were registered. The user callback functions are called and then the memory object is deleted
|
||||
* and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
|
||||
* notified when the memory referenced by host_ptr, specified when the memory object is created and used as
|
||||
* Registers a user callback function that will be called when the memory object is deleted and its resources
|
||||
* freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
|
||||
* stack associated with memobj. The registered user callback functions are called in the reverse order in
|
||||
* which they were registered. The user callback functions are called and then the memory object is deleted
|
||||
* and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
|
||||
* notified when the memory referenced by host_ptr, specified when the memory object is created and used as
|
||||
* the storage bits for the memory object, can be reused or freed.
|
||||
*
|
||||
* The application may not call CL api's with the cl_mem object passed to the pfn_notify.
|
||||
@@ -66,9 +66,9 @@ extern "C" {
|
||||
* before using.
|
||||
*/
|
||||
#define cl_APPLE_SetMemObjectDestructor 1
|
||||
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
|
||||
void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
|
||||
void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem memobj,
|
||||
void (* pfn_notify)(cl_mem memobj, void * user_data),
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/* Context Logging Functions
|
||||
@@ -77,29 +77,29 @@ cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
|
||||
* Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
|
||||
* before using.
|
||||
*
|
||||
* clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
|
||||
* clLogMessagesToSystemLog forwards on all log messages to the Apple System Logger
|
||||
*/
|
||||
#define cl_APPLE_ContextLoggingFunctions 1
|
||||
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
|
||||
const void * /* private_info */,
|
||||
size_t /* cb */,
|
||||
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
|
||||
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
|
||||
const void * /* private_info */,
|
||||
size_t /* cb */,
|
||||
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
|
||||
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
|
||||
const void * /* private_info */,
|
||||
size_t /* cb */,
|
||||
void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * errstr,
|
||||
const void * private_info,
|
||||
size_t cb,
|
||||
void * user_data) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/************************
|
||||
* cl_khr_icd extension *
|
||||
/************************
|
||||
* cl_khr_icd extension *
|
||||
************************/
|
||||
#define cl_khr_icd 1
|
||||
|
||||
@@ -110,55 +110,92 @@ extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */
|
||||
#define CL_PLATFORM_NOT_FOUND_KHR -1001
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
|
||||
cl_platform_id * /* platforms */,
|
||||
cl_uint * /* num_platforms */);
|
||||
clIcdGetPlatformIDsKHR(cl_uint num_entries,
|
||||
cl_platform_id * platforms,
|
||||
cl_uint * num_platforms);
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
|
||||
cl_uint /* num_entries */,
|
||||
cl_platform_id * /* platforms */,
|
||||
cl_uint * /* num_platforms */);
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(cl_uint num_entries,
|
||||
cl_platform_id * platforms,
|
||||
cl_uint * num_platforms);
|
||||
|
||||
|
||||
/* Extension: cl_khr_image2D_buffer
|
||||
*
|
||||
* This extension allows a 2D image to be created from a cl_mem buffer without a copy.
|
||||
* The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t.
|
||||
* Both the sampler and sampler-less read_image built-in functions are supported for 2D images
|
||||
* and 2D images created from a buffer. Similarly, the write_image built-ins are also supported
|
||||
* for 2D images created from a buffer.
|
||||
*
|
||||
* When the 2D image from buffer is created, the client must specify the width,
|
||||
* height, image format (i.e. channel order and channel data type) and optionally the row pitch
|
||||
*
|
||||
* The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels.
|
||||
* The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels.
|
||||
/*******************************
|
||||
* cl_khr_il_program extension *
|
||||
*******************************/
|
||||
#define cl_khr_il_program 1
|
||||
|
||||
/* New property to clGetDeviceInfo for retrieving supported intermediate
|
||||
* languages
|
||||
*/
|
||||
|
||||
/*************************************
|
||||
* cl_khr_initalize_memory extension *
|
||||
*************************************/
|
||||
|
||||
#define CL_DEVICE_IL_VERSION_KHR 0x105B
|
||||
|
||||
/* New property to clGetProgramInfo for retrieving for retrieving the IL of a
|
||||
* program
|
||||
*/
|
||||
#define CL_PROGRAM_IL_KHR 0x1169
|
||||
|
||||
extern CL_API_ENTRY cl_program CL_API_CALL
|
||||
clCreateProgramWithILKHR(cl_context context,
|
||||
const void * il,
|
||||
size_t length,
|
||||
cl_int * errcode_ret);
|
||||
|
||||
typedef CL_API_ENTRY cl_program
|
||||
(CL_API_CALL *clCreateProgramWithILKHR_fn)(cl_context context,
|
||||
const void * il,
|
||||
size_t length,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/* Extension: cl_khr_image2d_from_buffer
|
||||
*
|
||||
* This extension allows a 2D image to be created from a cl_mem buffer without
|
||||
* a copy. The type associated with a 2D image created from a buffer in an
|
||||
* OpenCL program is image2d_t. Both the sampler and sampler-less read_image
|
||||
* built-in functions are supported for 2D images and 2D images created from
|
||||
* a buffer. Similarly, the write_image built-ins are also supported for 2D
|
||||
* images created from a buffer.
|
||||
*
|
||||
* When the 2D image from buffer is created, the client must specify the
|
||||
* width, height, image format (i.e. channel order and channel data type)
|
||||
* and optionally the row pitch.
|
||||
*
|
||||
* The pitch specified must be a multiple of
|
||||
* CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR pixels.
|
||||
* The base address of the buffer must be aligned to
|
||||
* CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR pixels.
|
||||
*/
|
||||
|
||||
#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT_KHR 0x104A
|
||||
#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT_KHR 0x104B
|
||||
|
||||
|
||||
/**************************************
|
||||
* cl_khr_initialize_memory extension *
|
||||
**************************************/
|
||||
|
||||
#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x2030
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************
|
||||
* cl_khr_terminate_context extension *
|
||||
**************************************/
|
||||
|
||||
|
||||
#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x2031
|
||||
#define CL_CONTEXT_TERMINATE_KHR 0x2032
|
||||
|
||||
#define cl_khr_terminate_context 1
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clTerminateContextKHR(cl_context context) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clTerminateContextKHR_fn)(cl_context context) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
|
||||
/*
|
||||
* Extension: cl_khr_spir
|
||||
*
|
||||
* This extension adds support to create an OpenCL program object from a
|
||||
* This extension adds support to create an OpenCL program object from a
|
||||
* Standard Portable Intermediate Representation (SPIR) instance
|
||||
*/
|
||||
|
||||
@@ -166,9 +203,30 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /
|
||||
#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1
|
||||
|
||||
|
||||
/*****************************************
|
||||
* cl_khr_create_command_queue extension *
|
||||
*****************************************/
|
||||
#define cl_khr_create_command_queue 1
|
||||
|
||||
typedef cl_bitfield cl_queue_properties_khr;
|
||||
|
||||
extern CL_API_ENTRY cl_command_queue CL_API_CALL
|
||||
clCreateCommandQueueWithPropertiesKHR(cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_queue_properties_khr* properties,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
typedef CL_API_ENTRY cl_command_queue
|
||||
(CL_API_CALL *clCreateCommandQueueWithPropertiesKHR_fn)(cl_context context,
|
||||
cl_device_id device,
|
||||
const cl_queue_properties_khr* properties,
|
||||
cl_int* errcode_ret) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
|
||||
/******************************************
|
||||
* cl_nv_device_attribute_query extension *
|
||||
******************************************/
|
||||
|
||||
/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
|
||||
#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
|
||||
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
|
||||
@@ -190,6 +248,7 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /
|
||||
/*********************************
|
||||
* cl_amd_device_attribute_query *
|
||||
*********************************/
|
||||
|
||||
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
|
||||
#define CL_DEVICE_TOPOLOGY_AMD 0x4037
|
||||
#define CL_DEVICE_BOARD_NAME_AMD 0x4038
|
||||
@@ -382,14 +441,6 @@ typedef CL_API_ENTRY cl_mem
|
||||
#endif
|
||||
|
||||
// <amd_internal>
|
||||
/***************************
|
||||
* cl_amd_command_intercept *
|
||||
***************************/
|
||||
#define CL_CONTEXT_COMMAND_INTERCEPT_CALLBACK_AMD 0x403D
|
||||
#define CL_QUEUE_COMMAND_INTERCEPT_ENABLE_AMD (1ull << 63)
|
||||
|
||||
typedef cl_int (CL_CALLBACK * intercept_callback_fn)(cl_event, cl_int *);
|
||||
|
||||
/**************************
|
||||
* cl_amd_command_queue_info *
|
||||
**************************/
|
||||
@@ -426,86 +477,120 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL * clObjectSetValueForKeyAMD_fn)(
|
||||
void * /* value */) CL_API_SUFFIX__VERSION_1_1;
|
||||
// </amd_internal>
|
||||
|
||||
|
||||
/*********************************
|
||||
* cl_arm_printf extension
|
||||
*********************************/
|
||||
|
||||
#define CL_PRINTF_CALLBACK_ARM 0x40B0
|
||||
#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
|
||||
|
||||
#ifdef CL_VERSION_1_1
|
||||
/***********************************
|
||||
* cl_ext_device_fission extension *
|
||||
***********************************/
|
||||
#define cl_ext_device_fission 1
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
/***********************************
|
||||
* cl_ext_device_fission extension
|
||||
***********************************/
|
||||
#define cl_ext_device_fission 1
|
||||
|
||||
typedef cl_ulong cl_device_partition_property_ext;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clCreateSubDevicesEXT( cl_device_id /*in_device*/,
|
||||
const cl_device_partition_property_ext * /* properties */,
|
||||
cl_uint /*num_entries*/,
|
||||
cl_device_id * /*out_devices*/,
|
||||
cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clReleaseDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
|
||||
const cl_device_partition_property_ext * /* properties */,
|
||||
cl_uint /*num_entries*/,
|
||||
cl_device_id * /*out_devices*/,
|
||||
cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clReleaseDeviceEXT_fn)(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
/* cl_device_partition_property_ext */
|
||||
#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
|
||||
#define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
|
||||
#define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
|
||||
#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
|
||||
|
||||
/* clDeviceGetInfo selectors */
|
||||
#define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
|
||||
#define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
|
||||
#define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
|
||||
#define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
|
||||
#define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
|
||||
|
||||
/* clGetImageInfo enum */
|
||||
#define CL_IMAGE_BYTE_PITCH_AMD 0x4059
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clRetainDeviceEXT(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clRetainDeviceEXT_fn)(cl_device_id device) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef cl_ulong cl_device_partition_property_ext;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clCreateSubDevicesEXT(cl_device_id in_device,
|
||||
const cl_device_partition_property_ext * properties,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * out_devices,
|
||||
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL * clCreateSubDevicesEXT_fn)(cl_device_id in_device,
|
||||
const cl_device_partition_property_ext * properties,
|
||||
cl_uint num_entries,
|
||||
cl_device_id * out_devices,
|
||||
cl_uint * num_devices) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
/* cl_device_partition_property_ext */
|
||||
#define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
|
||||
#define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
|
||||
#define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
|
||||
#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
|
||||
|
||||
/* clDeviceGetInfo selectors */
|
||||
#define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
|
||||
#define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
|
||||
#define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
|
||||
#define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
|
||||
#define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
|
||||
|
||||
/* clGetImageInfo enum */
|
||||
#define CL_IMAGE_BYTE_PITCH_AMD 0x4059
|
||||
|
||||
/* error codes */
|
||||
#define CL_DEVICE_PARTITION_FAILED_EXT -1057
|
||||
#define CL_INVALID_PARTITION_COUNT_EXT -1058
|
||||
#define CL_INVALID_PARTITION_NAME_EXT -1059
|
||||
|
||||
/* CL_AFFINITY_DOMAINs */
|
||||
#define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
|
||||
#define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
|
||||
#define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
|
||||
#define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
|
||||
#define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
|
||||
#define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
|
||||
|
||||
/* cl_device_partition_property_ext list terminators */
|
||||
#define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
|
||||
#define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
|
||||
#define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
|
||||
|
||||
|
||||
/***********************************
|
||||
* cl_ext_migrate_memobject extension definitions
|
||||
***********************************/
|
||||
#define cl_ext_migrate_memobject 1
|
||||
|
||||
typedef cl_bitfield cl_mem_migration_flags_ext;
|
||||
|
||||
#define CL_MIGRATE_MEM_OBJECT_HOST_EXT 0x1
|
||||
|
||||
#define CL_COMMAND_MIGRATE_MEM_OBJECT_EXT 0x4040
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueMigrateMemObjectEXT(cl_command_queue command_queue,
|
||||
cl_uint num_mem_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_mem_migration_flags_ext flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL *clEnqueueMigrateMemObjectEXT_fn)(cl_command_queue command_queue,
|
||||
cl_uint num_mem_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_mem_migration_flags_ext flags,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event);
|
||||
|
||||
/* error codes */
|
||||
#define CL_DEVICE_PARTITION_FAILED_EXT -1057
|
||||
#define CL_INVALID_PARTITION_COUNT_EXT -1058
|
||||
#define CL_INVALID_PARTITION_NAME_EXT -1059
|
||||
|
||||
/* CL_AFFINITY_DOMAINs */
|
||||
#define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
|
||||
#define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
|
||||
#define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
|
||||
#define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
|
||||
#define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
|
||||
#define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
|
||||
|
||||
/* cl_device_partition_property_ext list terminators */
|
||||
#define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
|
||||
#define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
|
||||
#define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
|
||||
|
||||
/*********************************
|
||||
* cl_qcom_ext_host_ptr extension
|
||||
*********************************/
|
||||
#define cl_qcom_ext_host_ptr 1
|
||||
|
||||
#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
|
||||
|
||||
#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
|
||||
#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
|
||||
#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
|
||||
#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
|
||||
#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
|
||||
@@ -531,12 +616,21 @@ typedef struct _cl_mem_ext_host_ptr
|
||||
/* Type of external memory allocation. */
|
||||
/* Legal values will be defined in layered extensions. */
|
||||
cl_uint allocation_type;
|
||||
|
||||
|
||||
/* Host cache policy for this external memory allocation. */
|
||||
cl_uint host_cache_policy;
|
||||
|
||||
} cl_mem_ext_host_ptr;
|
||||
|
||||
|
||||
/*******************************************
|
||||
* cl_qcom_ext_host_ptr_iocoherent extension
|
||||
********************************************/
|
||||
|
||||
/* Cache policy specifying io-coherence */
|
||||
#define CL_MEM_HOST_IOCOHERENT_QCOM 0x40A9
|
||||
|
||||
|
||||
/*********************************
|
||||
* cl_qcom_ion_host_ptr extension
|
||||
*********************************/
|
||||
@@ -551,15 +645,30 @@ typedef struct _cl_mem_ion_host_ptr
|
||||
|
||||
/* ION file descriptor */
|
||||
int ion_filedesc;
|
||||
|
||||
|
||||
/* Host pointer to the ION allocated memory */
|
||||
void* ion_hostptr;
|
||||
|
||||
} cl_mem_ion_host_ptr;
|
||||
|
||||
#endif /* CL_VERSION_1_1 */
|
||||
|
||||
#if defined(CL_VERSION_1_2)
|
||||
/*********************************
|
||||
* cl_qcom_android_native_buffer_host_ptr extension
|
||||
*********************************/
|
||||
|
||||
#define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6
|
||||
|
||||
typedef struct _cl_mem_android_native_buffer_host_ptr
|
||||
{
|
||||
/* Type of external memory allocation. */
|
||||
/* Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. */
|
||||
cl_mem_ext_host_ptr ext_host_ptr;
|
||||
|
||||
/* Virtual pointer to the android native buffer */
|
||||
void* anb_ptr;
|
||||
|
||||
} cl_mem_android_native_buffer_host_ptr;
|
||||
|
||||
|
||||
/******************************************
|
||||
* cl_img_yuv_image extension *
|
||||
@@ -569,20 +678,23 @@ typedef struct _cl_mem_ion_host_ptr
|
||||
#define CL_NV21_IMG 0x40D0
|
||||
#define CL_YV12_IMG 0x40D1
|
||||
|
||||
|
||||
/******************************************
|
||||
* cl_img_cached_allocations extension *
|
||||
******************************************/
|
||||
|
||||
/* Flag values used by clCreteBuffer */
|
||||
#define CL_MEM_USE_UNCACHED_CPU_MEMORY_IMG (1 << 26)
|
||||
#define CL_MEM_USE_CACHED_CPU_MEMORY_IMG (1 << 27)
|
||||
/* Flag values used by clCreateBuffer */
|
||||
#define CL_MEM_USE_UNCACHED_CPU_MEMORY_IMG (1 << 26)
|
||||
#define CL_MEM_USE_CACHED_CPU_MEMORY_IMG (1 << 27)
|
||||
|
||||
|
||||
/******************************************
|
||||
* cl_img_use_gralloc_ptr extension *
|
||||
******************************************/
|
||||
#define cl_img_use_gralloc_ptr 1
|
||||
|
||||
/* Flag values used by clCreteBuffer */
|
||||
#define CL_MEM_USE_GRALLOC_PTR_IMG (1 << 28)
|
||||
/* Flag values used by clCreateBuffer */
|
||||
#define CL_MEM_USE_GRALLOC_PTR_IMG (1 << 28)
|
||||
|
||||
/* To be used by clGetEventInfo: */
|
||||
#define CL_COMMAND_ACQUIRE_GRALLOC_OBJECTS_IMG 0x40D2
|
||||
@@ -592,60 +704,75 @@ typedef struct _cl_mem_ion_host_ptr
|
||||
#define CL_GRALLOC_RESOURCE_NOT_ACQUIRED_IMG 0x40D4
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueAcquireGrallocObjectsIMG(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueAcquireGrallocObjectsIMG(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseGrallocObjectsIMG(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueReleaseGrallocObjectsIMG(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
#endif /* CL_VERSION_1_2 */
|
||||
|
||||
#ifdef CL_VERSION_2_0
|
||||
/*********************************
|
||||
* cl_khr_subgroups extension
|
||||
*********************************/
|
||||
#define cl_khr_subgroups 1
|
||||
|
||||
/* cl_kernel_sub_group_info is declared in CL.h. */
|
||||
#if !defined(CL_VERSION_2_1)
|
||||
/* For OpenCL 2.1 and newer, cl_kernel_sub_group_info is declared in CL.h.
|
||||
In hindsight, there should have been a khr suffix on this type for
|
||||
the extension, but keeping it un-suffixed to maintain backwards
|
||||
compatibility. */
|
||||
typedef cl_uint cl_kernel_sub_group_info;
|
||||
#endif
|
||||
|
||||
/* cl_kernel_sub_group_info */
|
||||
#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033
|
||||
#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034
|
||||
#define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033
|
||||
#define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
|
||||
cl_device_id /*in_device*/,
|
||||
cl_kernel_sub_group_info /* param_name */,
|
||||
size_t /*input_value_size*/,
|
||||
const void * /*input_value*/,
|
||||
size_t /*param_value_size*/,
|
||||
void* /*param_value*/,
|
||||
size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
( CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel /* in_kernel */,
|
||||
cl_device_id /*in_device*/,
|
||||
cl_kernel_sub_group_info /* param_name */,
|
||||
size_t /*input_value_size*/,
|
||||
const void * /*input_value*/,
|
||||
size_t /*param_value_size*/,
|
||||
void* /*param_value*/,
|
||||
size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
#endif /* CL_VERSION_2_0 */
|
||||
clGetKernelSubGroupInfoKHR(cl_kernel in_kernel,
|
||||
cl_device_id in_device,
|
||||
cl_kernel_sub_group_info param_name,
|
||||
size_t input_value_size,
|
||||
const void * input_value,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
|
||||
typedef CL_API_ENTRY cl_int
|
||||
(CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel in_kernel,
|
||||
cl_device_id in_device,
|
||||
cl_kernel_sub_group_info param_name,
|
||||
size_t input_value_size,
|
||||
const void * input_value,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED;
|
||||
|
||||
|
||||
/*********************************
|
||||
* cl_khr_mipmap_image extension
|
||||
*********************************/
|
||||
|
||||
/* cl_sampler_properties */
|
||||
#define CL_SAMPLER_MIP_FILTER_MODE_KHR 0x1155
|
||||
#define CL_SAMPLER_LOD_MIN_KHR 0x1156
|
||||
#define CL_SAMPLER_LOD_MAX_KHR 0x1157
|
||||
|
||||
|
||||
#ifdef CL_VERSION_2_1
|
||||
/*********************************
|
||||
* cl_khr_priority_hints extension
|
||||
*********************************/
|
||||
/* This extension define is for backwards compatibility.
|
||||
It shouldn't be required since this extension has no new functions. */
|
||||
#define cl_khr_priority_hints 1
|
||||
|
||||
typedef cl_uint cl_queue_priority_khr;
|
||||
@@ -658,12 +785,12 @@ typedef cl_uint cl_queue_priority_khr;
|
||||
#define CL_QUEUE_PRIORITY_MED_KHR (1<<1)
|
||||
#define CL_QUEUE_PRIORITY_LOW_KHR (1<<2)
|
||||
|
||||
#endif /* CL_VERSION_2_1 */
|
||||
|
||||
#ifdef CL_VERSION_2_1
|
||||
/*********************************
|
||||
* cl_khr_throttle_hints extension
|
||||
*********************************/
|
||||
/* This extension define is for backwards compatibility.
|
||||
It shouldn't be required since this extension has no new functions. */
|
||||
#define cl_khr_throttle_hints 1
|
||||
|
||||
typedef cl_uint cl_queue_throttle_khr;
|
||||
@@ -676,24 +803,65 @@ typedef cl_uint cl_queue_throttle_khr;
|
||||
#define CL_QUEUE_THROTTLE_MED_KHR (1<<1)
|
||||
#define CL_QUEUE_THROTTLE_LOW_KHR (1<<2)
|
||||
|
||||
#endif /* CL_VERSION_2_1 */
|
||||
|
||||
#ifdef CL_VERSION_2_2
|
||||
/*********************************
|
||||
* cl_khr_subgroup_named_barrier
|
||||
*********************************/
|
||||
/* This extension define is for backwards compatibility.
|
||||
It shouldn't be required since this extension has no new functions. */
|
||||
#define cl_khr_subgroup_named_barrier 1
|
||||
|
||||
/* cl_device_info */
|
||||
#define CL_DEVICE_MAX_NAMED_BARRIER_COUNT_KHR 0x2035
|
||||
|
||||
#endif /* CL_VERSION_2_2 */
|
||||
|
||||
/*********************************
|
||||
* cl_khr_extended_versioning
|
||||
*********************************/
|
||||
|
||||
#define CL_VERSION_MAJOR_BITS_KHR (10)
|
||||
#define CL_VERSION_MINOR_BITS_KHR (10)
|
||||
#define CL_VERSION_PATCH_BITS_KHR (12)
|
||||
|
||||
#define CL_VERSION_MAJOR_MASK_KHR ((1 << CL_VERSION_MAJOR_BITS_KHR) - 1)
|
||||
#define CL_VERSION_MINOR_MASK_KHR ((1 << CL_VERSION_MINOR_BITS_KHR) - 1)
|
||||
#define CL_VERSION_PATCH_MASK_KHR ((1 << CL_VERSION_PATCH_BITS_KHR) - 1)
|
||||
|
||||
#define CL_VERSION_MAJOR_KHR(version) ((version) >> (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR))
|
||||
#define CL_VERSION_MINOR_KHR(version) (((version) >> CL_VERSION_PATCH_BITS_KHR) & CL_VERSION_MINOR_MASK_KHR)
|
||||
#define CL_VERSION_PATCH_KHR(version) ((version) & CL_VERSION_PATCH_MASK_KHR)
|
||||
|
||||
#define CL_MAKE_VERSION_KHR(major, minor, patch) \
|
||||
((((major) & CL_VERSION_MAJOR_MASK_KHR) << (CL_VERSION_MINOR_BITS_KHR + CL_VERSION_PATCH_BITS_KHR)) | \
|
||||
(((minor) & CL_VERSION_MINOR_MASK_KHR) << CL_VERSION_PATCH_BITS_KHR) | \
|
||||
((patch) & CL_VERSION_PATCH_MASK_KHR))
|
||||
|
||||
typedef cl_uint cl_version_khr;
|
||||
|
||||
#define CL_NAME_VERSION_MAX_NAME_SIZE_KHR 64
|
||||
|
||||
typedef struct _cl_name_version_khr
|
||||
{
|
||||
cl_version_khr version;
|
||||
char name[CL_NAME_VERSION_MAX_NAME_SIZE_KHR];
|
||||
} cl_name_version_khr;
|
||||
|
||||
/* cl_platform_info */
|
||||
#define CL_PLATFORM_NUMERIC_VERSION_KHR 0x0906
|
||||
#define CL_PLATFORM_EXTENSIONS_WITH_VERSION_KHR 0x0907
|
||||
|
||||
/* cl_device_info */
|
||||
#define CL_DEVICE_NUMERIC_VERSION_KHR 0x105E
|
||||
#define CL_DEVICE_OPENCL_C_NUMERIC_VERSION_KHR 0x105F
|
||||
#define CL_DEVICE_EXTENSIONS_WITH_VERSION_KHR 0x1060
|
||||
#define CL_DEVICE_ILS_WITH_VERSION_KHR 0x1061
|
||||
#define CL_DEVICE_BUILT_IN_KERNELS_WITH_VERSION_KHR 0x1062
|
||||
|
||||
|
||||
/**********************************
|
||||
* cl_arm_import_memory extension *
|
||||
**********************************/
|
||||
|
||||
#ifdef CL_VERSION_1_0
|
||||
#define cl_arm_import_memory 1
|
||||
|
||||
typedef intptr_t cl_import_properties_arm;
|
||||
|
||||
@@ -706,8 +874,17 @@ typedef intptr_t cl_import_properties_arm;
|
||||
/* DMA BUF memory type value for CL_IMPORT_TYPE_ARM property */
|
||||
#define CL_IMPORT_TYPE_DMA_BUF_ARM 0x40B4
|
||||
|
||||
/* Secure DMA BUF memory type value for CL_IMPORT_TYPE_ARM property */
|
||||
#define CL_IMPORT_TYPE_SECURE_ARM 0x40B5
|
||||
/* Protected memory property */
|
||||
#define CL_IMPORT_TYPE_PROTECTED_ARM 0x40B5
|
||||
|
||||
/* Android hardware buffer type value for CL_IMPORT_TYPE_ARM property */
|
||||
#define CL_IMPORT_TYPE_ANDROID_HARDWARE_BUFFER_ARM 0x41E2
|
||||
|
||||
/* Data consistency with host property */
|
||||
#define CL_IMPORT_DMA_BUF_DATA_CONSISTENCY_WITH_HOST_ARM 0x41E3
|
||||
|
||||
/* Import memory size value to indicate a size for the whole buffer */
|
||||
#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX
|
||||
|
||||
/* This extension adds a new function that allows for direct memory import into
|
||||
* OpenCL via the clImportMemoryARM function.
|
||||
@@ -734,13 +911,10 @@ clImportMemoryARM( cl_context context,
|
||||
cl_int *errcode_ret) CL_EXT_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
#endif /* CL_VERSION_1_0 */
|
||||
|
||||
/******************************************
|
||||
* cl_arm_shared_virtual_memory extension *
|
||||
******************************************/
|
||||
|
||||
#ifdef CL_VERSION_1_2
|
||||
#define cl_arm_shared_virtual_memory 1
|
||||
|
||||
/* Used by clGetDeviceInfo */
|
||||
#define CL_DEVICE_SVM_CAPABILITIES_ARM 0x40B6
|
||||
@@ -774,76 +948,100 @@ typedef cl_uint cl_kernel_exec_info_arm;
|
||||
typedef cl_bitfield cl_device_svm_capabilities_arm;
|
||||
|
||||
extern CL_API_ENTRY void * CL_API_CALL
|
||||
clSVMAllocARM(cl_context /* context */,
|
||||
cl_svm_mem_flags_arm /* flags */,
|
||||
size_t /* size */,
|
||||
cl_uint /* alignment */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clSVMAllocARM(cl_context context,
|
||||
cl_svm_mem_flags_arm flags,
|
||||
size_t size,
|
||||
cl_uint alignment) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY void CL_API_CALL
|
||||
clSVMFreeARM(cl_context /* context */,
|
||||
void * /* svm_pointer */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clSVMFreeARM(cl_context context,
|
||||
void * svm_pointer) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMFreeARM(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_svm_pointers */,
|
||||
void *[] /* svm_pointers[] */,
|
||||
void (CL_CALLBACK * /*pfn_free_func*/)(cl_command_queue /* queue */,
|
||||
cl_uint /* num_svm_pointers */,
|
||||
void *[] /* svm_pointers[] */,
|
||||
void * /* user_data */),
|
||||
void * /* user_data */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueSVMFreeARM(cl_command_queue command_queue,
|
||||
cl_uint num_svm_pointers,
|
||||
void * svm_pointers[],
|
||||
void (CL_CALLBACK * pfn_free_func)(cl_command_queue queue,
|
||||
cl_uint num_svm_pointers,
|
||||
void * svm_pointers[],
|
||||
void * user_data),
|
||||
void * user_data,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMemcpyARM(cl_command_queue /* command_queue */,
|
||||
cl_bool /* blocking_copy */,
|
||||
void * /* dst_ptr */,
|
||||
const void * /* src_ptr */,
|
||||
size_t /* size */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueSVMMemcpyARM(cl_command_queue command_queue,
|
||||
cl_bool blocking_copy,
|
||||
void * dst_ptr,
|
||||
const void * src_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMemFillARM(cl_command_queue /* command_queue */,
|
||||
void * /* svm_ptr */,
|
||||
const void * /* pattern */,
|
||||
size_t /* pattern_size */,
|
||||
size_t /* size */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueSVMMemFillARM(cl_command_queue command_queue,
|
||||
void * svm_ptr,
|
||||
const void * pattern,
|
||||
size_t pattern_size,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMMapARM(cl_command_queue /* command_queue */,
|
||||
cl_bool /* blocking_map */,
|
||||
cl_map_flags /* flags */,
|
||||
void * /* svm_ptr */,
|
||||
size_t /* size */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueSVMMapARM(cl_command_queue command_queue,
|
||||
cl_bool blocking_map,
|
||||
cl_map_flags flags,
|
||||
void * svm_ptr,
|
||||
size_t size,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueSVMUnmapARM(cl_command_queue /* command_queue */,
|
||||
void * /* svm_ptr */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clEnqueueSVMUnmapARM(cl_command_queue command_queue,
|
||||
void * svm_ptr,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clSetKernelArgSVMPointerARM(cl_kernel /* kernel */,
|
||||
cl_uint /* arg_index */,
|
||||
const void * /* arg_value */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clSetKernelExecInfoARM(cl_kernel /* kernel */,
|
||||
cl_kernel_exec_info_arm /* param_name */,
|
||||
size_t /* param_value_size */,
|
||||
const void * /* param_value */) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
clSetKernelArgSVMPointerARM(cl_kernel kernel,
|
||||
cl_uint arg_index,
|
||||
const void * arg_value) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
#endif /* CL_VERSION_1_2 */
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clSetKernelExecInfoARM(cl_kernel kernel,
|
||||
cl_kernel_exec_info_arm param_name,
|
||||
size_t param_value_size,
|
||||
const void * param_value) CL_EXT_SUFFIX__VERSION_1_2;
|
||||
|
||||
/********************************
|
||||
* cl_arm_get_core_id extension *
|
||||
********************************/
|
||||
|
||||
#ifdef CL_VERSION_1_2
|
||||
|
||||
#define cl_arm_get_core_id 1
|
||||
|
||||
/* Device info property for bitfield of cores present */
|
||||
#define CL_DEVICE_COMPUTE_UNITS_BITFIELD_ARM 0x40BF
|
||||
|
||||
#endif /* CL_VERSION_1_2 */
|
||||
|
||||
/*********************************
|
||||
* cl_arm_job_slot_selection
|
||||
*********************************/
|
||||
|
||||
#define cl_arm_job_slot_selection 1
|
||||
|
||||
/* cl_device_info */
|
||||
#define CL_DEVICE_JOB_SLOTS_ARM 0x41E0
|
||||
|
||||
/* cl_command_queue_properties */
|
||||
#define CL_QUEUE_JOB_SLOT_ARM 0x41E1
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+72
-68
@@ -1,5 +1,5 @@
|
||||
/**********************************************************************************
|
||||
* Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
* Copyright (c) 2008-2019 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
@@ -29,11 +29,7 @@
|
||||
#ifndef __OPENCL_CL_GL_H
|
||||
#define __OPENCL_CL_GL_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -49,110 +45,118 @@ typedef struct __GLsync *cl_GLsync;
|
||||
#define CL_GL_OBJECT_TEXTURE2D 0x2001
|
||||
#define CL_GL_OBJECT_TEXTURE3D 0x2002
|
||||
#define CL_GL_OBJECT_RENDERBUFFER 0x2003
|
||||
#ifdef CL_VERSION_1_2
|
||||
#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E
|
||||
#define CL_GL_OBJECT_TEXTURE1D 0x200F
|
||||
#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010
|
||||
#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011
|
||||
#endif
|
||||
|
||||
/* cl_gl_texture_info */
|
||||
#define CL_GL_TEXTURE_TARGET 0x2004
|
||||
#define CL_GL_MIPMAP_LEVEL 0x2005
|
||||
#ifdef CL_VERSION_1_2
|
||||
#define CL_GL_NUM_SAMPLES 0x2012
|
||||
#endif
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromGLBuffer(cl_context /* context */,
|
||||
cl_mem_flags /* flags */,
|
||||
cl_GLuint /* bufobj */,
|
||||
int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clCreateFromGLBuffer(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_GLuint bufobj,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
#ifdef CL_VERSION_1_2
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromGLTexture(cl_context /* context */,
|
||||
cl_mem_flags /* flags */,
|
||||
cl_GLenum /* target */,
|
||||
cl_GLint /* miplevel */,
|
||||
cl_GLuint /* texture */,
|
||||
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
clCreateFromGLTexture(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
cl_GLuint texture,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2;
|
||||
|
||||
#endif
|
||||
|
||||
extern CL_API_ENTRY cl_mem CL_API_CALL
|
||||
clCreateFromGLRenderbuffer(cl_context /* context */,
|
||||
cl_mem_flags /* flags */,
|
||||
cl_GLuint /* renderbuffer */,
|
||||
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clCreateFromGLRenderbuffer(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_GLuint renderbuffer,
|
||||
cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetGLObjectInfo(cl_mem /* memobj */,
|
||||
cl_gl_object_type * /* gl_object_type */,
|
||||
cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetGLTextureInfo(cl_mem /* memobj */,
|
||||
cl_gl_texture_info /* param_name */,
|
||||
size_t /* param_value_size */,
|
||||
void * /* param_value */,
|
||||
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clGetGLObjectInfo(cl_mem memobj,
|
||||
cl_gl_object_type * gl_object_type,
|
||||
cl_GLuint * gl_object_name) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clGetGLTextureInfo(cl_mem memobj,
|
||||
cl_gl_texture_info param_name,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
|
||||
cl_uint /* num_objects */,
|
||||
const cl_mem * /* mem_objects */,
|
||||
cl_uint /* num_events_in_wait_list */,
|
||||
const cl_event * /* event_wait_list */,
|
||||
cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
|
||||
clEnqueueAcquireGLObjects(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clEnqueueReleaseGLObjects(cl_command_queue command_queue,
|
||||
cl_uint num_objects,
|
||||
const cl_mem * mem_objects,
|
||||
cl_uint num_events_in_wait_list,
|
||||
const cl_event * event_wait_list,
|
||||
cl_event * event) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
|
||||
/* Deprecated OpenCL 1.1 APIs */
|
||||
extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
|
||||
clCreateFromGLTexture2D(cl_context /* context */,
|
||||
cl_mem_flags /* flags */,
|
||||
cl_GLenum /* target */,
|
||||
cl_GLint /* miplevel */,
|
||||
cl_GLuint /* texture */,
|
||||
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
|
||||
|
||||
clCreateFromGLTexture2D(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
cl_GLuint texture,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
|
||||
|
||||
extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
|
||||
clCreateFromGLTexture3D(cl_context /* context */,
|
||||
cl_mem_flags /* flags */,
|
||||
cl_GLenum /* target */,
|
||||
cl_GLint /* miplevel */,
|
||||
cl_GLuint /* texture */,
|
||||
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
|
||||
|
||||
clCreateFromGLTexture3D(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
cl_GLenum target,
|
||||
cl_GLint miplevel,
|
||||
cl_GLuint texture,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
|
||||
|
||||
/* cl_khr_gl_sharing extension */
|
||||
|
||||
|
||||
#define cl_khr_gl_sharing 1
|
||||
|
||||
|
||||
typedef cl_uint cl_gl_context_info;
|
||||
|
||||
|
||||
/* Additional Error Codes */
|
||||
#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
|
||||
|
||||
|
||||
/* cl_gl_context_info */
|
||||
#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
|
||||
#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
|
||||
|
||||
|
||||
/* Additional cl_context_properties */
|
||||
#define CL_GL_CONTEXT_KHR 0x2008
|
||||
#define CL_EGL_DISPLAY_KHR 0x2009
|
||||
#define CL_GLX_DISPLAY_KHR 0x200A
|
||||
#define CL_WGL_HDC_KHR 0x200B
|
||||
#define CL_CGL_SHAREGROUP_KHR 0x200C
|
||||
|
||||
|
||||
extern CL_API_ENTRY cl_int CL_API_CALL
|
||||
clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
|
||||
cl_gl_context_info /* param_name */,
|
||||
size_t /* param_value_size */,
|
||||
void * /* param_value */,
|
||||
size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
clGetGLContextInfoKHR(const cl_context_properties * properties,
|
||||
cl_gl_context_info param_name,
|
||||
size_t param_value_size,
|
||||
void * param_value,
|
||||
size_t * param_value_size_ret) CL_API_SUFFIX__VERSION_1_0;
|
||||
|
||||
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
|
||||
const cl_context_properties * properties,
|
||||
cl_gl_context_info param_name,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**********************************************************************************
|
||||
* Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
* Copyright (c) 2008-2019 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
@@ -26,11 +26,6 @@
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
**********************************************************************************/
|
||||
|
||||
/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
|
||||
|
||||
/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
|
||||
/* OpenGL dependencies. */
|
||||
|
||||
#ifndef __OPENCL_CL_GL_EXT_H
|
||||
#define __OPENCL_CL_GL_EXT_H
|
||||
|
||||
@@ -38,34 +33,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#else
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For each extension, follow this template
|
||||
* cl_VEN_extname extension */
|
||||
/* #define cl_VEN_extname 1
|
||||
* ... define new types, if any
|
||||
* ... define new tokens, if any
|
||||
* ... define new APIs, if any
|
||||
*
|
||||
* If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
|
||||
* This allows us to avoid having to decide whether to include GL headers or GLES here.
|
||||
*/
|
||||
#include <CL/cl_gl.h>
|
||||
|
||||
/*
|
||||
* cl_khr_gl_event extension
|
||||
* See section 9.9 in the OpenCL 1.1 spec for more information
|
||||
* cl_khr_gl_event extension
|
||||
*/
|
||||
#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
|
||||
|
||||
extern CL_API_ENTRY cl_event CL_API_CALL
|
||||
clCreateEventFromGLsyncKHR(cl_context /* context */,
|
||||
cl_GLsync /* cl_GLsync */,
|
||||
cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
clCreateEventFromGLsyncKHR(cl_context context,
|
||||
cl_GLsync cl_GLsync,
|
||||
cl_int * errcode_ret) CL_EXT_SUFFIX__VERSION_1_1;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
Diff را بارگزاری کن
+164
-238
@@ -1,5 +1,5 @@
|
||||
/**********************************************************************************
|
||||
* Copyright (c) 2008-2015 The Khronos Group Inc.
|
||||
* Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
@@ -26,15 +26,10 @@
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
**********************************************************************************/
|
||||
|
||||
/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */
|
||||
|
||||
#ifndef __CL_PLATFORM_H
|
||||
#define __CL_PLATFORM_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
/* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
|
||||
#include <AvailabilityMacros.h>
|
||||
#endif
|
||||
#include <CL/cl_version.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -58,139 +53,70 @@ extern "C" {
|
||||
* deprecation but is deprecated in versions later than 1.1.
|
||||
*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
|
||||
#define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
|
||||
#define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
|
||||
|
||||
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
||||
#define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
||||
#define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
|
||||
#else
|
||||
#warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here!
|
||||
#define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
|
||||
#endif
|
||||
#define CL_EXTENSION_WEAK_LINK
|
||||
#define CL_API_SUFFIX__VERSION_1_0
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0
|
||||
#define CL_API_SUFFIX__VERSION_1_1
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1
|
||||
#define CL_API_SUFFIX__VERSION_1_2
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2
|
||||
#define CL_API_SUFFIX__VERSION_2_0
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0
|
||||
#define CL_API_SUFFIX__VERSION_2_1
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1
|
||||
#define CL_API_SUFFIX__VERSION_2_2
|
||||
#define CL_EXT_SUFFIX__VERSION_2_2
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CL_EXT_SUFFIX_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX_DEPRECATED
|
||||
#elif defined(_WIN32)
|
||||
#define CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define CL_EXTENSION_WEAK_LINK
|
||||
#define CL_API_SUFFIX__VERSION_1_0
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0
|
||||
#define CL_API_SUFFIX__VERSION_1_1
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1
|
||||
#define CL_API_SUFFIX__VERSION_1_2
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2
|
||||
#define CL_API_SUFFIX__VERSION_2_0
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0
|
||||
#define CL_API_SUFFIX__VERSION_2_1
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1
|
||||
#define CL_API_SUFFIX__VERSION_2_2
|
||||
#define CL_EXT_SUFFIX__VERSION_2_2
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
#endif
|
||||
#define CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
|
||||
#endif
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
|
||||
#endif
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED __attribute__((deprecated))
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
|
||||
#endif
|
||||
#elif defined(_WIN32)
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED __declspec(deprecated)
|
||||
#endif
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED __declspec(deprecated)
|
||||
#endif
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED __declspec(deprecated)
|
||||
#endif
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
|
||||
|
||||
#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
|
||||
|
||||
#define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
|
||||
|
||||
#define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED
|
||||
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
|
||||
#endif
|
||||
#ifdef CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED
|
||||
#else
|
||||
#define CL_EXT_SUFFIX__VERSION_2_1_DEPRECATED CL_EXT_SUFFIX_DEPRECATED
|
||||
#define CL_EXT_PREFIX__VERSION_2_1_DEPRECATED CL_EXT_PREFIX_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if (defined (_WIN32) && defined(_MSC_VER))
|
||||
@@ -300,16 +226,16 @@ typedef double cl_double;
|
||||
/* scalar types */
|
||||
typedef int8_t cl_char;
|
||||
typedef uint8_t cl_uchar;
|
||||
typedef int16_t cl_short __attribute__((aligned(2)));
|
||||
typedef uint16_t cl_ushort __attribute__((aligned(2)));
|
||||
typedef int32_t cl_int __attribute__((aligned(4)));
|
||||
typedef uint32_t cl_uint __attribute__((aligned(4)));
|
||||
typedef int64_t cl_long __attribute__((aligned(8)));
|
||||
typedef uint64_t cl_ulong __attribute__((aligned(8)));
|
||||
typedef int16_t cl_short;
|
||||
typedef uint16_t cl_ushort;
|
||||
typedef int32_t cl_int;
|
||||
typedef uint32_t cl_uint;
|
||||
typedef int64_t cl_long;
|
||||
typedef uint64_t cl_ulong;
|
||||
|
||||
typedef uint16_t cl_half __attribute__((aligned(2)));
|
||||
typedef float cl_float __attribute__((aligned(4)));
|
||||
typedef double cl_double __attribute__((aligned(8)));
|
||||
typedef uint16_t cl_half;
|
||||
typedef float cl_float;
|
||||
typedef double cl_double;
|
||||
|
||||
/* Macro names and corresponding values defined by OpenCL */
|
||||
#define CL_CHAR_BIT 8
|
||||
@@ -397,7 +323,7 @@ typedef double cl_double __attribute__((aligned(8)));
|
||||
#define CL_HUGE_VALF ((cl_float) 1e50)
|
||||
#define CL_HUGE_VAL ((cl_double) 1e500)
|
||||
float nanf( const char * );
|
||||
#define CL_NAN nanf( "" )
|
||||
#define CL_NAN nanf( "" )
|
||||
#endif
|
||||
#define CL_MAXFLOAT CL_FLT_MAX
|
||||
#define CL_INFINITY CL_HUGE_VALF
|
||||
@@ -412,17 +338,17 @@ typedef int cl_GLint;
|
||||
typedef unsigned int cl_GLenum;
|
||||
|
||||
/*
|
||||
* Vector types
|
||||
* Vector types
|
||||
*
|
||||
* Note: OpenCL requires that all types be naturally aligned.
|
||||
* Note: OpenCL requires that all types be naturally aligned.
|
||||
* This means that vector types must be naturally aligned.
|
||||
* For example, a vector of four floats must be aligned to
|
||||
* a 16 byte boundary (calculated as 4 * the natural 4-byte
|
||||
* a 16 byte boundary (calculated as 4 * the natural 4-byte
|
||||
* alignment of the float). The alignment qualifiers here
|
||||
* will only function properly if your compiler supports them
|
||||
* and if you don't actively work to defeat them. For example,
|
||||
* in order for a cl_float4 to be 16 byte aligned in a struct,
|
||||
* the start of the struct must itself be 16-byte aligned.
|
||||
* the start of the struct must itself be 16-byte aligned.
|
||||
*
|
||||
* Maintaining proper alignment is the user's responsibility.
|
||||
*/
|
||||
@@ -430,13 +356,13 @@ typedef unsigned int cl_GLenum;
|
||||
/* Define basic vector types */
|
||||
#if defined( __VEC__ )
|
||||
#include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
|
||||
typedef vector unsigned char __cl_uchar16;
|
||||
typedef vector signed char __cl_char16;
|
||||
typedef vector unsigned short __cl_ushort8;
|
||||
typedef vector signed short __cl_short8;
|
||||
typedef vector unsigned int __cl_uint4;
|
||||
typedef vector signed int __cl_int4;
|
||||
typedef vector float __cl_float4;
|
||||
typedef __vector unsigned char __cl_uchar16;
|
||||
typedef __vector signed char __cl_char16;
|
||||
typedef __vector unsigned short __cl_ushort8;
|
||||
typedef __vector signed short __cl_short8;
|
||||
typedef __vector unsigned int __cl_uint4;
|
||||
typedef __vector signed int __cl_int4;
|
||||
typedef __vector float __cl_float4;
|
||||
#define __CL_UCHAR16__ 1
|
||||
#define __CL_CHAR16__ 1
|
||||
#define __CL_USHORT8__ 1
|
||||
@@ -536,7 +462,7 @@ typedef unsigned int cl_GLenum;
|
||||
#if defined( __MINGW64__ )
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#include <immintrin.h>
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
#if defined( __GNUC__ )
|
||||
typedef cl_float __cl_float8 __attribute__((vector_size(32)));
|
||||
@@ -605,7 +531,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_char s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_char lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_CHAR2__)
|
||||
#if defined( __CL_CHAR2__)
|
||||
__cl_char2 v2;
|
||||
#endif
|
||||
}cl_char2;
|
||||
@@ -618,10 +544,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_CHAR2__)
|
||||
#if defined( __CL_CHAR2__)
|
||||
__cl_char2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_CHAR4__)
|
||||
#if defined( __CL_CHAR4__)
|
||||
__cl_char4 v4;
|
||||
#endif
|
||||
}cl_char4;
|
||||
@@ -637,10 +563,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_CHAR2__)
|
||||
#if defined( __CL_CHAR2__)
|
||||
__cl_char2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_CHAR4__)
|
||||
#if defined( __CL_CHAR4__)
|
||||
__cl_char4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_CHAR8__ )
|
||||
@@ -656,10 +582,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_CHAR2__)
|
||||
#if defined( __CL_CHAR2__)
|
||||
__cl_char2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_CHAR4__)
|
||||
#if defined( __CL_CHAR4__)
|
||||
__cl_char4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_CHAR8__ )
|
||||
@@ -680,7 +606,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; };
|
||||
#endif
|
||||
#if defined( __cl_uchar2__)
|
||||
#if defined( __cl_uchar2__)
|
||||
__cl_uchar2 v2;
|
||||
#endif
|
||||
}cl_uchar2;
|
||||
@@ -693,10 +619,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UCHAR2__)
|
||||
#if defined( __CL_UCHAR2__)
|
||||
__cl_uchar2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_UCHAR4__)
|
||||
#if defined( __CL_UCHAR4__)
|
||||
__cl_uchar4 v4;
|
||||
#endif
|
||||
}cl_uchar4;
|
||||
@@ -712,10 +638,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UCHAR2__)
|
||||
#if defined( __CL_UCHAR2__)
|
||||
__cl_uchar2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_UCHAR4__)
|
||||
#if defined( __CL_UCHAR4__)
|
||||
__cl_uchar4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_UCHAR8__ )
|
||||
@@ -731,10 +657,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UCHAR2__)
|
||||
#if defined( __CL_UCHAR2__)
|
||||
__cl_uchar2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_UCHAR4__)
|
||||
#if defined( __CL_UCHAR4__)
|
||||
__cl_uchar4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_UCHAR8__ )
|
||||
@@ -755,7 +681,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_short s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_short lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_SHORT2__)
|
||||
#if defined( __CL_SHORT2__)
|
||||
__cl_short2 v2;
|
||||
#endif
|
||||
}cl_short2;
|
||||
@@ -768,10 +694,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_SHORT2__)
|
||||
#if defined( __CL_SHORT2__)
|
||||
__cl_short2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_SHORT4__)
|
||||
#if defined( __CL_SHORT4__)
|
||||
__cl_short4 v4;
|
||||
#endif
|
||||
}cl_short4;
|
||||
@@ -787,10 +713,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_SHORT2__)
|
||||
#if defined( __CL_SHORT2__)
|
||||
__cl_short2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_SHORT4__)
|
||||
#if defined( __CL_SHORT4__)
|
||||
__cl_short4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_SHORT8__ )
|
||||
@@ -806,10 +732,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_SHORT2__)
|
||||
#if defined( __CL_SHORT2__)
|
||||
__cl_short2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_SHORT4__)
|
||||
#if defined( __CL_SHORT4__)
|
||||
__cl_short4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_SHORT8__ )
|
||||
@@ -830,7 +756,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_USHORT2__)
|
||||
#if defined( __CL_USHORT2__)
|
||||
__cl_ushort2 v2;
|
||||
#endif
|
||||
}cl_ushort2;
|
||||
@@ -843,10 +769,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_USHORT2__)
|
||||
#if defined( __CL_USHORT2__)
|
||||
__cl_ushort2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_USHORT4__)
|
||||
#if defined( __CL_USHORT4__)
|
||||
__cl_ushort4 v4;
|
||||
#endif
|
||||
}cl_ushort4;
|
||||
@@ -862,10 +788,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_USHORT2__)
|
||||
#if defined( __CL_USHORT2__)
|
||||
__cl_ushort2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_USHORT4__)
|
||||
#if defined( __CL_USHORT4__)
|
||||
__cl_ushort4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_USHORT8__ )
|
||||
@@ -881,10 +807,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_USHORT2__)
|
||||
#if defined( __CL_USHORT2__)
|
||||
__cl_ushort2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_USHORT4__)
|
||||
#if defined( __CL_USHORT4__)
|
||||
__cl_ushort4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_USHORT8__ )
|
||||
@@ -905,7 +831,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_half s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_half lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_HALF2__)
|
||||
#if defined( __CL_HALF2__)
|
||||
__cl_half2 v2;
|
||||
#endif
|
||||
}cl_half2;
|
||||
@@ -918,10 +844,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_half2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_HALF2__)
|
||||
#if defined( __CL_HALF2__)
|
||||
__cl_half2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_HALF4__)
|
||||
#if defined( __CL_HALF4__)
|
||||
__cl_half4 v4;
|
||||
#endif
|
||||
}cl_half4;
|
||||
@@ -937,10 +863,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_half4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_HALF2__)
|
||||
#if defined( __CL_HALF2__)
|
||||
__cl_half2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_HALF4__)
|
||||
#if defined( __CL_HALF4__)
|
||||
__cl_half4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_HALF8__ )
|
||||
@@ -956,10 +882,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_half s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_half8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_HALF2__)
|
||||
#if defined( __CL_HALF2__)
|
||||
__cl_half2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_HALF4__)
|
||||
#if defined( __CL_HALF4__)
|
||||
__cl_half4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_HALF8__ )
|
||||
@@ -979,7 +905,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_int s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_int lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_INT2__)
|
||||
#if defined( __CL_INT2__)
|
||||
__cl_int2 v2;
|
||||
#endif
|
||||
}cl_int2;
|
||||
@@ -992,10 +918,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_INT2__)
|
||||
#if defined( __CL_INT2__)
|
||||
__cl_int2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_INT4__)
|
||||
#if defined( __CL_INT4__)
|
||||
__cl_int4 v4;
|
||||
#endif
|
||||
}cl_int4;
|
||||
@@ -1011,10 +937,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_INT2__)
|
||||
#if defined( __CL_INT2__)
|
||||
__cl_int2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_INT4__)
|
||||
#if defined( __CL_INT4__)
|
||||
__cl_int4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_INT8__ )
|
||||
@@ -1030,10 +956,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_INT2__)
|
||||
#if defined( __CL_INT2__)
|
||||
__cl_int2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_INT4__)
|
||||
#if defined( __CL_INT4__)
|
||||
__cl_int4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_INT8__ )
|
||||
@@ -1054,7 +980,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UINT2__)
|
||||
#if defined( __CL_UINT2__)
|
||||
__cl_uint2 v2;
|
||||
#endif
|
||||
}cl_uint2;
|
||||
@@ -1067,10 +993,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UINT2__)
|
||||
#if defined( __CL_UINT2__)
|
||||
__cl_uint2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_UINT4__)
|
||||
#if defined( __CL_UINT4__)
|
||||
__cl_uint4 v4;
|
||||
#endif
|
||||
}cl_uint4;
|
||||
@@ -1086,10 +1012,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UINT2__)
|
||||
#if defined( __CL_UINT2__)
|
||||
__cl_uint2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_UINT4__)
|
||||
#if defined( __CL_UINT4__)
|
||||
__cl_uint4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_UINT8__ )
|
||||
@@ -1105,10 +1031,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_UINT2__)
|
||||
#if defined( __CL_UINT2__)
|
||||
__cl_uint2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_UINT4__)
|
||||
#if defined( __CL_UINT4__)
|
||||
__cl_uint4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_UINT8__ )
|
||||
@@ -1128,7 +1054,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_long s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_long lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_LONG2__)
|
||||
#if defined( __CL_LONG2__)
|
||||
__cl_long2 v2;
|
||||
#endif
|
||||
}cl_long2;
|
||||
@@ -1141,10 +1067,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_LONG2__)
|
||||
#if defined( __CL_LONG2__)
|
||||
__cl_long2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_LONG4__)
|
||||
#if defined( __CL_LONG4__)
|
||||
__cl_long4 v4;
|
||||
#endif
|
||||
}cl_long4;
|
||||
@@ -1160,10 +1086,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_LONG2__)
|
||||
#if defined( __CL_LONG2__)
|
||||
__cl_long2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_LONG4__)
|
||||
#if defined( __CL_LONG4__)
|
||||
__cl_long4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_LONG8__ )
|
||||
@@ -1179,10 +1105,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_LONG2__)
|
||||
#if defined( __CL_LONG2__)
|
||||
__cl_long2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_LONG4__)
|
||||
#if defined( __CL_LONG4__)
|
||||
__cl_long4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_LONG8__ )
|
||||
@@ -1203,7 +1129,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_ULONG2__)
|
||||
#if defined( __CL_ULONG2__)
|
||||
__cl_ulong2 v2;
|
||||
#endif
|
||||
}cl_ulong2;
|
||||
@@ -1216,10 +1142,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_ULONG2__)
|
||||
#if defined( __CL_ULONG2__)
|
||||
__cl_ulong2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_ULONG4__)
|
||||
#if defined( __CL_ULONG4__)
|
||||
__cl_ulong4 v4;
|
||||
#endif
|
||||
}cl_ulong4;
|
||||
@@ -1235,10 +1161,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_ULONG2__)
|
||||
#if defined( __CL_ULONG2__)
|
||||
__cl_ulong2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_ULONG4__)
|
||||
#if defined( __CL_ULONG4__)
|
||||
__cl_ulong4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_ULONG8__ )
|
||||
@@ -1254,10 +1180,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_ULONG2__)
|
||||
#if defined( __CL_ULONG2__)
|
||||
__cl_ulong2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_ULONG4__)
|
||||
#if defined( __CL_ULONG4__)
|
||||
__cl_ulong4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_ULONG8__ )
|
||||
@@ -1279,7 +1205,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_float s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_float lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_FLOAT2__)
|
||||
#if defined( __CL_FLOAT2__)
|
||||
__cl_float2 v2;
|
||||
#endif
|
||||
}cl_float2;
|
||||
@@ -1292,10 +1218,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_FLOAT2__)
|
||||
#if defined( __CL_FLOAT2__)
|
||||
__cl_float2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_FLOAT4__)
|
||||
#if defined( __CL_FLOAT4__)
|
||||
__cl_float4 v4;
|
||||
#endif
|
||||
}cl_float4;
|
||||
@@ -1311,10 +1237,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_FLOAT2__)
|
||||
#if defined( __CL_FLOAT2__)
|
||||
__cl_float2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_FLOAT4__)
|
||||
#if defined( __CL_FLOAT4__)
|
||||
__cl_float4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_FLOAT8__ )
|
||||
@@ -1330,10 +1256,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_FLOAT2__)
|
||||
#if defined( __CL_FLOAT2__)
|
||||
__cl_float2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_FLOAT4__)
|
||||
#if defined( __CL_FLOAT4__)
|
||||
__cl_float4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_FLOAT8__ )
|
||||
@@ -1354,7 +1280,7 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
__cl_double2 v2;
|
||||
#endif
|
||||
}cl_double2;
|
||||
@@ -1367,10 +1293,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
__cl_double2 v2[2];
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
__cl_double4 v4;
|
||||
#endif
|
||||
}cl_double4;
|
||||
@@ -1386,10 +1312,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
__cl_double2 v2[4];
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
__cl_double4 v4[2];
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE8__ )
|
||||
@@ -1405,10 +1331,10 @@ typedef union
|
||||
__CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
|
||||
__CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
#if defined( __CL_DOUBLE2__)
|
||||
__cl_double2 v2[8];
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
#if defined( __CL_DOUBLE4__)
|
||||
__cl_double4 v4[4];
|
||||
#endif
|
||||
#if defined( __CL_DOUBLE8__ )
|
||||
@@ -1419,9 +1345,9 @@ typedef union
|
||||
#endif
|
||||
}cl_double16;
|
||||
|
||||
/* Macro to facilitate debugging
|
||||
/* Macro to facilitate debugging
|
||||
* Usage:
|
||||
* Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
|
||||
* Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
|
||||
* The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
|
||||
* Each line thereafter of OpenCL C source must end with: \n\
|
||||
* The last line ends in ";
|
||||
@@ -1436,13 +1362,13 @@ typedef union
|
||||
* } \n\
|
||||
* ";
|
||||
*
|
||||
* This should correctly set up the line, (column) and file information for your source
|
||||
* This should correctly set up the line, (column) and file information for your source
|
||||
* string so you can do source level debugging.
|
||||
*/
|
||||
#define __CL_STRINGIFY( _x ) # _x
|
||||
#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
|
||||
#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
|
||||
|
||||
#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 The Khronos Group Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
* "Materials"), to deal in the Materials without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
* permit persons to whom the Materials are furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Materials.
|
||||
*
|
||||
* MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
|
||||
* KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
|
||||
* SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
|
||||
* https://www.khronos.org/registry/
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __CL_VERSION_H
|
||||
#define __CL_VERSION_H
|
||||
|
||||
/* Detect which version to target */
|
||||
#if !defined(CL_TARGET_OPENCL_VERSION)
|
||||
#pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)")
|
||||
#define CL_TARGET_OPENCL_VERSION 220
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION != 100 && \
|
||||
CL_TARGET_OPENCL_VERSION != 110 && \
|
||||
CL_TARGET_OPENCL_VERSION != 120 && \
|
||||
CL_TARGET_OPENCL_VERSION != 200 && \
|
||||
CL_TARGET_OPENCL_VERSION != 210 && \
|
||||
CL_TARGET_OPENCL_VERSION != 220
|
||||
#pragma message("cl_version: CL_TARGET_OPENCL_VERSION is not a valid value (100, 110, 120, 200, 210, 220). Defaulting to 220 (OpenCL 2.2)")
|
||||
#undef CL_TARGET_OPENCL_VERSION
|
||||
#define CL_TARGET_OPENCL_VERSION 220
|
||||
#endif
|
||||
|
||||
|
||||
/* OpenCL Version */
|
||||
#if CL_TARGET_OPENCL_VERSION >= 220 && !defined(CL_VERSION_2_2)
|
||||
#define CL_VERSION_2_2 1
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION >= 210 && !defined(CL_VERSION_2_1)
|
||||
#define CL_VERSION_2_1 1
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION >= 200 && !defined(CL_VERSION_2_0)
|
||||
#define CL_VERSION_2_0 1
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION >= 120 && !defined(CL_VERSION_1_2)
|
||||
#define CL_VERSION_1_2 1
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION >= 110 && !defined(CL_VERSION_1_1)
|
||||
#define CL_VERSION_1_1 1
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION >= 100 && !defined(CL_VERSION_1_0)
|
||||
#define CL_VERSION_1_0 1
|
||||
#endif
|
||||
|
||||
/* Allow deprecated APIs for older OpenCL versions. */
|
||||
#if CL_TARGET_OPENCL_VERSION <= 210 && !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS)
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION <= 200 && !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS)
|
||||
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION <= 120 && !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS)
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION <= 110 && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS)
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
|
||||
#endif
|
||||
#if CL_TARGET_OPENCL_VERSION <= 100 && !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS)
|
||||
#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
|
||||
#endif
|
||||
|
||||
#endif /* __CL_VERSION_H */
|
||||
@@ -35,25 +35,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <OpenCL/cl.h>
|
||||
#include <OpenCL/cl_gl.h>
|
||||
#include <OpenCL/cl_gl_ext.h>
|
||||
#include <OpenCL/cl_ext.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <CL/cl.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#include <CL/cl_gl_ext.h>
|
||||
#include <CL/cl_ext.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OPENCL_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
/* Copyright (c) 2008-present Advanced Micro Devices, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE. */
|
||||
|
||||
#include "cl_common.hpp"
|
||||
#include "vdi_common.hpp"
|
||||
#ifdef _WIN32
|
||||
#include <d3d10_1.h>
|
||||
#include "cl_d3d9_amd.hpp"
|
||||
#include "cl_d3d10_amd.hpp"
|
||||
#include "cl_d3d11_amd.hpp"
|
||||
#endif //_WIN32
|
||||
|
||||
#include <icd/loader/icd_dispatch.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
amd::PlatformIDS amd::PlatformID::Platform = //{ NULL };
|
||||
{amd::ICDDispatchedObject::icdVendorDispatch_};
|
||||
|
||||
static cl_int CL_API_CALL icdGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
|
||||
size_t param_value_size, void* param_value,
|
||||
size_t* param_value_size_ret) {
|
||||
return clGetPlatformInfo(NULL, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
static cl_int CL_API_CALL icdGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
|
||||
cl_uint num_entries, cl_device_id* devices,
|
||||
cl_uint* num_devices) {
|
||||
return clGetDeviceIDs(NULL, device_type, num_entries, devices, num_devices);
|
||||
}
|
||||
|
||||
static cl_int CL_API_CALL icdGetDeviceInfo(cl_device_id device, cl_device_info param_name,
|
||||
size_t param_value_size, void* param_value,
|
||||
size_t* param_value_size_ret) {
|
||||
if (param_name == CL_DEVICE_PLATFORM) {
|
||||
// Return the ICD platform instead of the default NULL platform.
|
||||
cl_platform_id platform = reinterpret_cast<cl_platform_id>(&amd::PlatformID::Platform);
|
||||
return amd::clGetInfo(platform, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
return clGetDeviceInfo(device, param_name, param_value_size, param_value, param_value_size_ret);
|
||||
}
|
||||
|
||||
cl_icd_dispatch amd::ICDDispatchedObject::icdVendorDispatch_[] = {
|
||||
{NULL /* should not get called */, icdGetPlatformInfo, icdGetDeviceIDs, icdGetDeviceInfo,
|
||||
clCreateContext, clCreateContextFromType, clRetainContext, clReleaseContext, clGetContextInfo,
|
||||
clCreateCommandQueue, clRetainCommandQueue, clReleaseCommandQueue, clGetCommandQueueInfo,
|
||||
clSetCommandQueueProperty, clCreateBuffer, clCreateImage2D, clCreateImage3D, clRetainMemObject,
|
||||
clReleaseMemObject, clGetSupportedImageFormats, clGetMemObjectInfo, clGetImageInfo,
|
||||
clCreateSampler, clRetainSampler, clReleaseSampler, clGetSamplerInfo,
|
||||
clCreateProgramWithSource, clCreateProgramWithBinary, clRetainProgram, clReleaseProgram,
|
||||
clBuildProgram, clUnloadCompiler, clGetProgramInfo, clGetProgramBuildInfo, clCreateKernel,
|
||||
clCreateKernelsInProgram, clRetainKernel, clReleaseKernel, clSetKernelArg, clGetKernelInfo,
|
||||
clGetKernelWorkGroupInfo, clWaitForEvents, clGetEventInfo, clRetainEvent, clReleaseEvent,
|
||||
clGetEventProfilingInfo, clFlush, clFinish, clEnqueueReadBuffer, clEnqueueWriteBuffer,
|
||||
clEnqueueCopyBuffer, clEnqueueReadImage, clEnqueueWriteImage, clEnqueueCopyImage,
|
||||
clEnqueueCopyImageToBuffer, clEnqueueCopyBufferToImage, clEnqueueMapBuffer, clEnqueueMapImage,
|
||||
clEnqueueUnmapMemObject, clEnqueueNDRangeKernel, clEnqueueTask, clEnqueueNativeKernel,
|
||||
clEnqueueMarker, clEnqueueWaitForEvents, clEnqueueBarrier, clGetExtensionFunctionAddress,
|
||||
clCreateFromGLBuffer, clCreateFromGLTexture2D, clCreateFromGLTexture3D,
|
||||
clCreateFromGLRenderbuffer, clGetGLObjectInfo, clGetGLTextureInfo, clEnqueueAcquireGLObjects,
|
||||
clEnqueueReleaseGLObjects, clGetGLContextInfoKHR,
|
||||
WINDOWS_SWITCH(clGetDeviceIDsFromD3D10KHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D10BufferKHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D10Texture2DKHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D10Texture3DKHR, NULL),
|
||||
WINDOWS_SWITCH(clEnqueueAcquireD3D10ObjectsKHR, NULL),
|
||||
WINDOWS_SWITCH(clEnqueueReleaseD3D10ObjectsKHR, NULL), clSetEventCallback, clCreateSubBuffer,
|
||||
clSetMemObjectDestructorCallback, clCreateUserEvent, clSetUserEventStatus,
|
||||
clEnqueueReadBufferRect, clEnqueueWriteBufferRect, clEnqueueCopyBufferRect,
|
||||
NULL, NULL, NULL, clCreateEventFromGLsyncKHR,
|
||||
|
||||
/* OpenCL 1.2*/
|
||||
clCreateSubDevices, clRetainDevice, clReleaseDevice, clCreateImage,
|
||||
clCreateProgramWithBuiltInKernels, clCompileProgram, clLinkProgram, clUnloadPlatformCompiler,
|
||||
clGetKernelArgInfo, clEnqueueFillBuffer, clEnqueueFillImage, clEnqueueMigrateMemObjects,
|
||||
clEnqueueMarkerWithWaitList, clEnqueueBarrierWithWaitList,
|
||||
clGetExtensionFunctionAddressForPlatform, clCreateFromGLTexture,
|
||||
|
||||
WINDOWS_SWITCH(clGetDeviceIDsFromD3D11KHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D11BufferKHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D11Texture2DKHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromD3D11Texture3DKHR, NULL),
|
||||
WINDOWS_SWITCH(clCreateFromDX9MediaSurfaceKHR, NULL),
|
||||
WINDOWS_SWITCH(clEnqueueAcquireD3D11ObjectsKHR, NULL),
|
||||
WINDOWS_SWITCH(clEnqueueReleaseD3D11ObjectsKHR, NULL),
|
||||
|
||||
WINDOWS_SWITCH(clGetDeviceIDsFromDX9MediaAdapterKHR,
|
||||
NULL), // KHRpfn_clGetDeviceIDsFromDX9MediaAdapterKHR
|
||||
// clGetDeviceIDsFromDX9MediaAdapterKHR;
|
||||
WINDOWS_SWITCH(
|
||||
clEnqueueAcquireDX9MediaSurfacesKHR,
|
||||
NULL), // KHRpfn_clEnqueueAcquireDX9MediaSurfacesKHR clEnqueueAcquireDX9MediaSurfacesKHR;
|
||||
WINDOWS_SWITCH(
|
||||
clEnqueueReleaseDX9MediaSurfacesKHR,
|
||||
NULL), // KHRpfn_clEnqueueReleaseDX9MediaSurfacesKHR clEnqueueReleaseDX9MediaSurfacesKHR;
|
||||
|
||||
NULL,
|
||||
NULL, NULL, NULL,
|
||||
|
||||
clCreateCommandQueueWithProperties, clCreatePipe, clGetPipeInfo, clSVMAlloc, clSVMFree,
|
||||
clEnqueueSVMFree, clEnqueueSVMMemcpy, clEnqueueSVMMemFill, clEnqueueSVMMap, clEnqueueSVMUnmap,
|
||||
clCreateSamplerWithProperties, clSetKernelArgSVMPointer, clSetKernelExecInfo,
|
||||
clGetKernelSubGroupInfo,
|
||||
clCloneKernel,
|
||||
clCreateProgramWithIL,
|
||||
clEnqueueSVMMigrateMem,
|
||||
clGetDeviceAndHostTimer,
|
||||
clGetHostTimer,
|
||||
clGetKernelSubGroupInfo,
|
||||
clSetDefaultDeviceCommandQueue,
|
||||
|
||||
clSetProgramReleaseCallback,
|
||||
clSetProgramSpecializationConstant }};
|
||||
|
||||
#if defined(ATI_OS_WIN)
|
||||
#include <Shlwapi.h>
|
||||
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
|
||||
static bool ShouldLoadPlatform() {
|
||||
// Get the OpenCL ICD registry values
|
||||
HKEY platformsKey = NULL;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Khronos\\OpenCL\\Vendors", 0, KEY_READ,
|
||||
&platformsKey) != ERROR_SUCCESS)
|
||||
return true;
|
||||
|
||||
std::vector<std::string> registryValues;
|
||||
DWORD dwIndex = 0;
|
||||
while (true) {
|
||||
char cszLibraryName[1024] = {0};
|
||||
DWORD dwLibraryNameSize = sizeof(cszLibraryName);
|
||||
DWORD dwLibraryNameType = 0;
|
||||
DWORD dwValue = 0;
|
||||
DWORD dwValueSize = sizeof(dwValue);
|
||||
|
||||
if (RegEnumValueA(platformsKey, dwIndex++, cszLibraryName, &dwLibraryNameSize, NULL,
|
||||
&dwLibraryNameType, (LPBYTE)&dwValue, &dwValueSize) != ERROR_SUCCESS)
|
||||
break;
|
||||
// Require that the value be a DWORD and equal zero
|
||||
if (dwLibraryNameType != REG_DWORD || dwValue != 0) {
|
||||
continue;
|
||||
}
|
||||
registryValues.push_back(cszLibraryName);
|
||||
}
|
||||
RegCloseKey(platformsKey);
|
||||
|
||||
HMODULE hm = NULL;
|
||||
if (!GetModuleHandleExA(
|
||||
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
|
||||
(LPCSTR)&ShouldLoadPlatform, &hm))
|
||||
return true;
|
||||
|
||||
char cszDllPath[1024] = {0};
|
||||
if (!GetModuleFileNameA(hm, cszDllPath, sizeof(cszDllPath))) return true;
|
||||
|
||||
// If we are loaded from the DriverStore, then there should be a registry
|
||||
// value matching our current module absolute path.
|
||||
if (std::find(registryValues.begin(), registryValues.end(), cszDllPath) == registryValues.end())
|
||||
return true;
|
||||
|
||||
LPSTR cszFileName;
|
||||
char buffer[1024] = {0};
|
||||
if (!GetFullPathNameA(cszDllPath, sizeof(buffer), buffer, &cszFileName)) return true;
|
||||
|
||||
// We found an absolute path in the registry that matched this DLL, now
|
||||
// check if there is also an entry with the same filename.
|
||||
if (std::find(registryValues.begin(), registryValues.end(), cszFileName) == registryValues.end())
|
||||
return true;
|
||||
|
||||
// Lastly, check if there is a DLL with the same name in the System folder.
|
||||
char cszSystemPath[1024] = {0};
|
||||
#if defined(ATI_BITS_32)
|
||||
if (!GetSystemWow64DirectoryA(cszSystemPath, sizeof(cszSystemPath)))
|
||||
#endif // defined(ATI_BITS_32)
|
||||
if (!GetSystemDirectoryA(cszSystemPath, sizeof(cszSystemPath))) return true;
|
||||
|
||||
std::string systemDllPath;
|
||||
systemDllPath.append(cszSystemPath).append("\\").append(cszFileName);
|
||||
if (!PathFileExistsA(systemDllPath.c_str())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we get here, then all 3 conditions are true:
|
||||
// - An entry in the registry with an absolute path matches the current DLL
|
||||
// - An entry in the registry with a relative path matches the current DLL
|
||||
// - A DLL with the same name was found in the system directory
|
||||
//
|
||||
// We should not load this platform!
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
// If there is only one platform, load it.
|
||||
// If there is more than one platform, only load platforms that have visible devices
|
||||
// If all platforms have no devices available, only load the PAL platform
|
||||
static bool ShouldLoadPlatform() {
|
||||
bool shouldLoad = true;
|
||||
|
||||
if (!amd::Runtime::initialized()) {
|
||||
amd::Runtime::init();
|
||||
}
|
||||
const int numDevices = amd::Device::numDevices(CL_DEVICE_TYPE_GPU, false);
|
||||
|
||||
void *otherPlatform = nullptr;
|
||||
if (amd::IS_LEGACY) {
|
||||
otherPlatform = dlopen("libamdocl64.so", RTLD_LAZY);
|
||||
if (otherPlatform != nullptr) { // Present platform exists
|
||||
shouldLoad = numDevices > 0;
|
||||
}
|
||||
} else {
|
||||
otherPlatform = dlopen("libamdocl-orca64.so", RTLD_LAZY);
|
||||
if (otherPlatform != nullptr) { // Legacy platform exists
|
||||
// gcc4.8 doesn't support casting void* to a function pointer
|
||||
// Work around this by creating a typedef untill we upgrade the compiler
|
||||
typedef void*(*clGetFunctionAddress_t)(const char *);
|
||||
typedef cl_int(*clIcdGetPlatformIDs_t)(cl_uint, cl_platform_id *, cl_uint *);
|
||||
|
||||
clGetFunctionAddress_t legacyGetFunctionAddress =
|
||||
reinterpret_cast<clGetFunctionAddress_t>(dlsym(otherPlatform, "clGetExtensionFunctionAddress"));
|
||||
clIcdGetPlatformIDs_t legacyGetPlatformIDs =
|
||||
reinterpret_cast<clIcdGetPlatformIDs_t>(legacyGetFunctionAddress("clIcdGetPlatformIDsKHR"));
|
||||
|
||||
cl_uint numLegacyPlatforms = 0;
|
||||
legacyGetPlatformIDs(0, nullptr, &numLegacyPlatforms);
|
||||
|
||||
shouldLoad = (numDevices > 0) || (numLegacyPlatforms == 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (otherPlatform != nullptr) {
|
||||
dlclose(otherPlatform);
|
||||
}
|
||||
|
||||
return shouldLoad;
|
||||
}
|
||||
|
||||
#endif // defined(ATI_OS_WIN)
|
||||
|
||||
CL_API_ENTRY cl_int CL_API_CALL clIcdGetPlatformIDsKHR(cl_uint num_entries,
|
||||
cl_platform_id* platforms,
|
||||
cl_uint* num_platforms) {
|
||||
if (((num_entries > 0 || num_platforms == NULL) && platforms == NULL) ||
|
||||
(num_entries == 0 && platforms != NULL)) {
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
static bool shouldLoad = true;
|
||||
|
||||
static std::once_flag initOnce;
|
||||
std::call_once(initOnce, [](){ shouldLoad = ShouldLoadPlatform(); });
|
||||
|
||||
if (!shouldLoad) {
|
||||
*not_null(num_platforms) = 0;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
if (!amd::Runtime::initialized()) {
|
||||
amd::Runtime::init();
|
||||
}
|
||||
|
||||
if (num_platforms != NULL && platforms == NULL) {
|
||||
*num_platforms = 1;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
assert(platforms != NULL && "check the code above");
|
||||
*platforms = reinterpret_cast<cl_platform_id>(&amd::PlatformID::Platform);
|
||||
|
||||
*not_null(num_platforms) = 1;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
Diff را بارگزاری کن
+20
-9
@@ -133,6 +133,7 @@ if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "VDI" and !defined $HIP_VDI_HOME) {
|
||||
} else {
|
||||
$HIP_VDI_HOME = $HIP_PATH; # use HIP_PATH
|
||||
}
|
||||
$HIPCXXFLAGS .= "-D__HIP_VDI__";
|
||||
}
|
||||
|
||||
if (defined $HIP_VDI_HOME) {
|
||||
@@ -221,8 +222,8 @@ if ($HIP_PLATFORM eq "clang") {
|
||||
|
||||
$HSA_PATH=$ENV{'HSA_PATH'} // "$ROCM_PATH/hsa";
|
||||
$HIPCXXFLAGS .= " -isystem $HSA_PATH/include";
|
||||
if (! $HIP_RUNTIME eq "HCC" ) {
|
||||
$HIPCXXFLAGS .= " -fhip-new-launch-api";
|
||||
if (!($HIP_RUNTIME eq "HCC")) {
|
||||
$HIPCXXFLAGS .= " -D__HIP_VDI__ -fhip-new-launch-api";
|
||||
}
|
||||
|
||||
} elsif ($HIP_PLATFORM eq "hcc") {
|
||||
@@ -390,6 +391,7 @@ my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool
|
||||
my $optArg = ""; # -O args
|
||||
my $targetOpt = '--amdgpu-target=';
|
||||
my $targetsStr = "";
|
||||
my $skipOutputFile = 0; # file followed by -o should not contibute in picking compiler flags
|
||||
|
||||
foreach $arg (@ARGV)
|
||||
{
|
||||
@@ -401,8 +403,16 @@ foreach $arg (@ARGV)
|
||||
$needCXXFLAGS = 1;
|
||||
$needLDFLAGS = 0;
|
||||
}
|
||||
|
||||
if ($skipOutputFile) {
|
||||
$toolArgs .= " $arg";
|
||||
$skipOutputFile = 0;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($arg eq '-o') {
|
||||
$needLDFLAGS = 1;
|
||||
$skipOutputFile = 1;
|
||||
}
|
||||
|
||||
if(($trimarg eq '-stdlib=libc++') and ($setStdLib eq 0))
|
||||
@@ -469,13 +479,6 @@ foreach $arg (@ARGV)
|
||||
$optArg = $arg;
|
||||
}
|
||||
|
||||
## This is a temporary workaround for CMake detection of OpenMP support.
|
||||
## It should be removed when the OpenMP detection c++ test in CMake is updated
|
||||
## and corrected CMake version is available.
|
||||
if((defined $HIP_COMPILER) and ($HIP_COMPILER eq "clang") and ($arg eq '-fopenmp')) {
|
||||
$HIPCXXFLAGS .= " -D_OPENMP "
|
||||
}
|
||||
|
||||
## process linker response file for hip-clang
|
||||
## extract object files from static library and pass them directly to
|
||||
## hip-clang in command line.
|
||||
@@ -726,6 +729,14 @@ if ($HIP_PLATFORM eq "clang") {
|
||||
$HIPCXXFLAGS .= " -O3";
|
||||
$HIPLDFLAGS .= " -O3";
|
||||
}
|
||||
# Do not pass -mllvm on Windows since there is a clang bug causing duplicate -mllvm options in clang -cc1 on Windows.
|
||||
# ToDo : remove restriction for Windows after clang bug is fixed.
|
||||
if ($optArg ne "-O0" and not $isWindows) {
|
||||
$HIPCXXFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false";
|
||||
if ($needLDFLAGS and not $needCXXFLAGS) {
|
||||
$HIPLDFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false";
|
||||
}
|
||||
}
|
||||
$HIP_DEVLIB_FLAGS = " --hip-device-lib-path=$DEVICE_LIB_PATH";
|
||||
$HIPCXXFLAGS .= " $HIP_DEVLIB_FLAGS";
|
||||
if (not $isWindows) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
$HIP_BASE_VERSION_MAJOR = "3";
|
||||
$HIP_BASE_VERSION_MINOR = "1";
|
||||
$HIP_BASE_VERSION_MINOR = "2";
|
||||
|
||||
# Need perl > 5.10 to use logic-defined or
|
||||
use 5.006; use v5.10.1;
|
||||
|
||||
@@ -223,6 +223,10 @@ sub simpleSubstitutions {
|
||||
$ft{'memory'} += s/\bcuMemcpy2DAsync\b/hipMemcpyParam2DAsync/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy2DAsync_v2\b/hipMemcpyParam2DAsync/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy2D_v2\b/hipMemcpyParam2D/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy3D\b/hipDrvMemcpy3D/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy3DAsync\b/hipDrvMemcpy3DAsync/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy3D_v2\b/hipDrvMemcpy3D/g;
|
||||
$ft{'memory'} += s/\bcuMemcpy3DAsync_v2\b/hipDrvMemcpy3DAsync/g;
|
||||
$ft{'memory'} += s/\bcuMemcpyAtoH\b/hipMemcpyAtoH/g;
|
||||
$ft{'memory'} += s/\bcuMemcpyAtoH_v2\b/hipMemcpyAtoH/g;
|
||||
$ft{'memory'} += s/\bcuMemcpyDtoD\b/hipMemcpyDtoD/g;
|
||||
@@ -938,6 +942,8 @@ sub simpleSubstitutions {
|
||||
$ft{'type'} += s/\bCUDA_ARRAY_DESCRIPTOR_st\b/HIP_ARRAY_DESCRIPTOR/g;
|
||||
$ft{'type'} += s/\bCUDA_MEMCPY2D\b/hip_Memcpy2D/g;
|
||||
$ft{'type'} += s/\bCUDA_MEMCPY2D_st\b/hip_Memcpy2D/g;
|
||||
$ft{'type'} += s/\bCUDA_MEMCPY3D\b/HIP_MEMCPY3D/g;
|
||||
$ft{'type'} += s/\bCUDA_MEMCPY3D_st\b/HIP_MEMCPY3D/g;
|
||||
$ft{'type'} += s/\bCUaddress_mode\b/hipTextureAddressMode/g;
|
||||
$ft{'type'} += s/\bCUaddress_mode_enum\b/hipTextureAddressMode/g;
|
||||
$ft{'type'} += s/\bCUarray\b/hipArray */g;
|
||||
@@ -1172,6 +1178,7 @@ sub simpleSubstitutions {
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_ASSERT\b/hipErrorAssert/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_CONTEXT_ALREADY_CURRENT\b/hipErrorContextAlreadyCurrent/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_CONTEXT_ALREADY_IN_USE\b/hipErrorContextAlreadyInUse/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE\b/hipErrorCooperativeLaunchTooLarge/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_DEINITIALIZED\b/hipErrorDeinitialized/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_ECC_UNCORRECTABLE\b/hipErrorECCNotCorrectable/g;
|
||||
$ft{'numeric_literal'} += s/\bCUDA_ERROR_FILE_NOT_FOUND\b/hipErrorFileNotFound/g;
|
||||
@@ -1528,6 +1535,7 @@ sub simpleSubstitutions {
|
||||
$ft{'numeric_literal'} += s/\bCU_MEMORYTYPE_UNIFIED\b/hipMemoryTypeUnified/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_MEM_ATTACH_GLOBAL\b/hipMemAttachGlobal/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_MEM_ATTACH_HOST\b/hipMemAttachHost/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_OCCUPANCY_DEFAULT\b/hipOccupancyDefault/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_RESOURCE_TYPE_ARRAY\b/hipResourceTypeArray/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_RESOURCE_TYPE_LINEAR\b/hipResourceTypeLinear/g;
|
||||
$ft{'numeric_literal'} += s/\bCU_RESOURCE_TYPE_MIPMAPPED_ARRAY\b/hipResourceTypeMipmappedArray/g;
|
||||
@@ -1636,6 +1644,7 @@ sub simpleSubstitutions {
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorAlreadyMapped\b/hipErrorAlreadyMapped/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorArrayIsMapped\b/hipErrorArrayIsMapped/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorAssert\b/hipErrorAssert/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorCooperativeLaunchTooLarge\b/hipErrorCooperativeLaunchTooLarge/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorCudartUnloading\b/hipErrorDeinitialized/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorDeviceAlreadyInUse\b/hipErrorContextAlreadyInUse/g;
|
||||
$ft{'numeric_literal'} += s/\bcudaErrorDeviceUninitialized\b/hipErrorInvalidContext/g;
|
||||
@@ -1749,6 +1758,8 @@ sub simpleSubstitutions {
|
||||
$ft{'define'} += s/\bCUDA_ARRAY3D_LAYERED\b/hipArrayLayered/g;
|
||||
$ft{'define'} += s/\bCUDA_ARRAY3D_SURFACE_LDST\b/hipArraySurfaceLoadStore/g;
|
||||
$ft{'define'} += s/\bCUDA_ARRAY3D_TEXTURE_GATHER\b/hipArrayTextureGather/g;
|
||||
$ft{'define'} += s/\bCUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC\b/hipCooperativeLaunchMultiDeviceNoPostSync/g;
|
||||
$ft{'define'} += s/\bCUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC\b/hipCooperativeLaunchMultiDeviceNoPreSync/g;
|
||||
$ft{'define'} += s/\bCU_LAUNCH_PARAM_BUFFER_POINTER\b/HIP_LAUNCH_PARAM_BUFFER_POINTER/g;
|
||||
$ft{'define'} += s/\bCU_LAUNCH_PARAM_BUFFER_SIZE\b/HIP_LAUNCH_PARAM_BUFFER_SIZE/g;
|
||||
$ft{'define'} += s/\bCU_LAUNCH_PARAM_END\b/HIP_LAUNCH_PARAM_END/g;
|
||||
@@ -1769,6 +1780,8 @@ sub simpleSubstitutions {
|
||||
$ft{'define'} += s/\bcudaArrayLayered\b/hipArrayLayered/g;
|
||||
$ft{'define'} += s/\bcudaArraySurfaceLoadStore\b/hipArraySurfaceLoadStore/g;
|
||||
$ft{'define'} += s/\bcudaArrayTextureGather\b/hipArrayTextureGather/g;
|
||||
$ft{'define'} += s/\bcudaCooperativeLaunchMultiDeviceNoPostSync\b/hipCooperativeLaunchMultiDeviceNoPostSync/g;
|
||||
$ft{'define'} += s/\bcudaCooperativeLaunchMultiDeviceNoPreSync\b/hipCooperativeLaunchMultiDeviceNoPreSync/g;
|
||||
$ft{'define'} += s/\bcudaDeviceBlockingSync\b/hipDeviceScheduleBlockingSync/g;
|
||||
$ft{'define'} += s/\bcudaDeviceLmemResizeToMax\b/hipDeviceLmemResizeToMax/g;
|
||||
$ft{'define'} += s/\bcudaDeviceMapHost\b/hipDeviceMapHost/g;
|
||||
@@ -1792,6 +1805,7 @@ sub simpleSubstitutions {
|
||||
$ft{'define'} += s/\bcudaIpcMemLazyEnablePeerAccess\b/hipIpcMemLazyEnablePeerAccess/g;
|
||||
$ft{'define'} += s/\bcudaMemAttachGlobal\b/hipMemAttachGlobal/g;
|
||||
$ft{'define'} += s/\bcudaMemAttachHost\b/hipMemAttachHost/g;
|
||||
$ft{'define'} += s/\bcudaOccupancyDefault\b/hipOccupancyDefault/g;
|
||||
$ft{'define'} += s/\bcudaStreamDefault\b/hipStreamDefault/g;
|
||||
$ft{'define'} += s/\bcudaStreamNonBlocking\b/hipStreamNonBlocking/g;
|
||||
$ft{'define'} += s/\bcudaTextureType1D\b/hipTextureType1D/g;
|
||||
|
||||
@@ -447,6 +447,7 @@
|
||||
| 717 |*`CUDA_ERROR_INVALID_ADDRESS_SPACE`* | |
|
||||
| 718 |*`CUDA_ERROR_INVALID_PC`* | |
|
||||
| 719 |*`CUDA_ERROR_LAUNCH_FAILED`* |*`hipErrorLaunchFailure`* |
|
||||
| 720 |*`CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE`* |*`hipErrorCooperativeLaunchTooLarge`* |
|
||||
| 800 |*`CUDA_ERROR_NOT_PERMITTED`* | |
|
||||
| 801 |*`CUDA_ERROR_NOT_SUPPORTED`* |*`hipErrorNotSupported`* |
|
||||
| 802 |*`CUDA_ERROR_SYSTEM_NOT_READY`* | | 10.0 |
|
||||
@@ -1125,10 +1126,10 @@
|
||||
|
||||
| **CUDA** | **HIP** |**CUDA version\***|
|
||||
|-----------------------------------------------------------|---------------------------------------------------------|------------------|
|
||||
| `cuOccupancyMaxActiveBlocksPerMultiprocessor` |`hipOccupancyMaxActiveBlocksPerMultiprocessor` |
|
||||
| `cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` |`hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` |
|
||||
| `cuOccupancyMaxPotentialBlockSize` |`hipOccupancyMaxPotentialBlockSize` |
|
||||
| `cuOccupancyMaxPotentialBlockSizeWithFlags` | |
|
||||
| `cuOccupancyMaxActiveBlocksPerMultiprocessor` |`hipDrvOccupancyMaxActiveBlocksPerMultiprocessor` |
|
||||
| `cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` |`hipDrvOccupancyMaxActiveBlocksPerMultiprocessorWithFlags` |
|
||||
| `cuOccupancyMaxPotentialBlockSize` |`hipOccupancyMaxPotentialBlockSize` |
|
||||
| `cuOccupancyMaxPotentialBlockSizeWithFlags` | |
|
||||
|
||||
## **22. Texture Reference Management [DEPRECATED]**
|
||||
|
||||
|
||||
@@ -800,7 +800,7 @@
|
||||
| 717 |*`cudaErrorInvalidAddressSpace`* | | |
|
||||
| 718 |*`cudaErrorInvalidPc`* | | |
|
||||
| 719 |*`cudaErrorLaunchFailure`* | |*`hipErrorLaunchFailure`* |
|
||||
| 720 |*`cudaErrorCooperativeLaunchTooLarge`* | 9.0 | |
|
||||
| 720 |*`cudaErrorCooperativeLaunchTooLarge`* | 9.0 |*`hipErrorCooperativeLaunchTooLarge`* |
|
||||
| 800 |*`cudaErrorNotPermitted`* | | |
|
||||
| 801 |*`cudaErrorNotSupported`* | |*`hipErrorNotSupported`* |
|
||||
| 802 |*`cudaErrorSystemNotReady`* | 10.0 | |
|
||||
@@ -1045,7 +1045,7 @@
|
||||
| define |`cudaMemAttachGlobal` | |`hipMemAttachGlobal` |
|
||||
| define |`cudaMemAttachHost` | |`hipMemAttachHost` |
|
||||
| define |`cudaMemAttachSingle` | | |
|
||||
| define |`cudaOccupancyDefault` | | |
|
||||
| define |`cudaOccupancyDefault` | |`hipOccupancyDefault` |
|
||||
| define |`cudaOccupancyDisableCachingOverride` | | |
|
||||
| define |`cudaPeerAccessDefault` | | |
|
||||
| define |`cudaStreamDefault` | |`hipStreamDefault` |
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# Profiling HIP Code
|
||||
|
||||
This section describes the tracing and debugging capabilities that HIP provides.
|
||||
<!-- toc -->
|
||||
|
||||
- [Tracing and Debug](#tracing-and-debug)
|
||||
* [Tracing HIP APIs](#tracing-hip-apis)
|
||||
+ [Color](#color)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Tracing and Debug
|
||||
|
||||
### Tracing HIP APIs
|
||||
The HIP runtime can print the HIP function strings to stderr using HIP_TRACE_API environment variable.
|
||||
The trace prints two messages for each API - one at the beginning of the API call (line starts with "<<") and one at the end of the API call (line ends with ">>").
|
||||
Here's an example for one API followed by a description for the sections of the trace:
|
||||
|
||||
```
|
||||
<<hip-api tid:1.6 hipMemcpy (0x7f32154db010, 0x50446e000, 4000000, hipMemcpyDeviceToHost)
|
||||
hip-api tid:1.6 hipMemcpy ret= 0 (hipSuccess)>>
|
||||
```
|
||||
|
||||
- `<<hip-api` is the header used for all HIP API debug messages. The message is also shown in a specific color. This can be used to distinguish this API from other HIP or application messages.
|
||||
- `tid:1.6` indicates that this API call came from thread #1 and is the 6th API call in that thread. When the first API in a new thread is called, HIP will associates a short sequential ID with that thread. You can see the full thread ID (reported by C++) as 0x7f6183b097c0 in the example below.
|
||||
- `hipMemcpy` is the name of the API.
|
||||
- The first line then prints a comma-separated list of the arguments to the function. APIs which return values to the caller by writing to pointers will show the pointer addresses rather than the pointer contents. This behavior may change in the future.
|
||||
- The second line shows the completion of the API, including the numeric return value (`ret= 0`) as well as an string representation for the error code (`hipSuccess`). If the returned error code is non-zero, then the csecond line message is shown in red (unless HIP_TRACE_API_COLOR is "none" - see below).
|
||||
|
||||
|
||||
Heres a specific example showing the output of the [square](https://github.com/ROCm-Developer-Tools/HIP/tree/master/samples/0_Intro/square) program running on HIP:
|
||||
|
||||
```
|
||||
$ HIP_TRACE_API=1 ./square.hip.out
|
||||
hip-api tid:1:HIP initialized short_tid#1 (maps to full_tid: 0x7f6183b097c0)
|
||||
<<hip-api tid:1.1 hipGetDeviceProperties (0x7ffddb673e08, 0)
|
||||
hip-api tid:1.1 hipGetDeviceProperties ret= 0 (hipSuccess)>>
|
||||
info: running on device gfx803
|
||||
info: allocate host mem ( 7.63 MB)
|
||||
info: allocate device mem ( 7.63 MB)
|
||||
<<hip-api tid:1.2 hipMalloc (0x7ffddb673fb8, 4000000)
|
||||
hip-api tid:1.2 hipMalloc ret= 0 (hipSuccess)>>
|
||||
<<hip-api tid:1.3 hipMalloc (0x7ffddb673fb0, 4000000)
|
||||
hip-api tid:1.3 hipMalloc ret= 0 (hipSuccess)>>
|
||||
info: copy Host2Device
|
||||
<<hip-api tid:1.4 hipMemcpy (0x50409d000, 0x7f32158ac010, 4000000, hipMemcpyHostToDevice)
|
||||
hip-api tid:1.4 hipMemcpy ret= 0 (hipSuccess)>>
|
||||
info: launch 'vector_square' kernel
|
||||
1.5 hipLaunchKernel 'HIP_KERNEL_NAME(vector_square)' gridDim:{512,1,1} groupDim:{256,1,1} sharedMem:+0 stream#0.0
|
||||
info: copy Device2Host
|
||||
<<hip-api tid:1.6 hipMemcpy (0x7f32154db010, 0x50446e000, 4000000, hipMemcpyDeviceToHost)
|
||||
hip-api tid:1.6 hipMemcpy ret= 0 (hipSuccess)>>
|
||||
info: check result
|
||||
PASSED!
|
||||
```
|
||||
|
||||
HIP_TRACE_API supports multiple levels of debug information:
|
||||
- 0x1 = print all HIP APIs. This is the most verbose setting; the flags below allow selecting a subset.
|
||||
- 0x2 = print HIP APIs which initiate GPU kernel commands. Includes hipLaunchKernel, hipLaunchModuleKernel
|
||||
- 0x4 = print HIP APIs which initiate GPU memory commands. Includes hipMemcpy*, hipMemset*.
|
||||
- 0x8 = print HIP APIs which allocate or free memory. Includes hipMalloc, hipHostMalloc, hipFree, hipHostFree.
|
||||
|
||||
These can be combined. For example, HIP_TRACE_API=6 shows a concise view of the HIP commands (both kernel and memory) that are sent to the GPU.
|
||||
|
||||
|
||||
#### Color
|
||||
Note this trace mode uses colors. "less -r" can handle raw control characters and will display the debug output in proper colors.
|
||||
You can change the color used for the trace mode with the HIP_TRACE_API_COLOR environment variable. Possible values are None/Red/Green/Yellow/Blue/Magenta/Cyan/White.
|
||||
None will disable use of color control codes for both the opening and closing and may be useful when saving the trace file or when a pure text trace is desired.
|
||||
|
||||
|
||||
|
||||
@@ -50,9 +50,46 @@ set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" )
|
||||
set_and_check(hip_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc")
|
||||
set_and_check(hip_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig")
|
||||
|
||||
get_filename_component(HIP_CLANG_ROOT "${CMAKE_CXX_COMPILER}" PATH)
|
||||
get_filename_component(HIP_CLANG_ROOT "${HIP_CLANG_ROOT}" PATH)
|
||||
file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS ${HIP_CLANG_ROOT}/lib/clang/*/include)
|
||||
find_path(HIP_CLANG_INCLUDE_PATH stddef.h
|
||||
HINTS
|
||||
${HIP_CLANG_INCLUDE_SEARCH_PATHS}
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
find_dependency(amd_comgr)
|
||||
find_dependency(AMDDeviceLibs)
|
||||
set(AMDGPU_TARGETS "gfx900;gfx906" CACHE STRING "AMD GPU targets to compile for")
|
||||
set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "GPU targets to compile for")
|
||||
|
||||
include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" )
|
||||
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_COMPILE_OPTIONS -x hip --hip-device-lib-path=${AMD_DEVICE_LIBS_PREFIX}/lib
|
||||
)
|
||||
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES --hip-device-lib-path=${AMD_DEVICE_LIBS_PREFIX}/lib --hip-link
|
||||
)
|
||||
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}"
|
||||
)
|
||||
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${HIP_CLANG_INCLUDE_PATH}"
|
||||
)
|
||||
|
||||
foreach(GPU_TARGET ${GPU_TARGETS})
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_COMPILE_OPTIONS "--cuda-gpu-arch=${GPU_TARGET}"
|
||||
)
|
||||
set_property(TARGET hip::device APPEND PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "--cuda-gpu-arch=${GPU_TARGET}"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
set( hip_LIBRARIES hip::host hip::device)
|
||||
set( hip_LIBRARY ${hip_LIBRARIES})
|
||||
|
||||
|
||||
+2
-1
@@ -447,7 +447,8 @@ if len(sys.argv) > 3: OUTPUT = sys.argv[3]
|
||||
|
||||
# API declaration map
|
||||
api_map = {
|
||||
'hipHccModuleLaunchKernel': ''
|
||||
'hipHccModuleLaunchKernel': '',
|
||||
'hipExtModuleLaunchKernel': ''
|
||||
}
|
||||
# API options map
|
||||
opts_map = {}
|
||||
|
||||
+19
-17
@@ -42,10 +42,10 @@ After applying all the matchers, the output HIP source is produced.
|
||||
|
||||
`hipify-clang` requires:
|
||||
|
||||
1. [**LLVM+CLANG**](http://releases.llvm.org) of at least version [3.8.0](http://releases.llvm.org/download.html#3.8.0); the latest stable and recommended release: [**9.0.1**](http://releases.llvm.org/download.html#9.0.1), the latest release candidate: [10.0.0-rc1](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc1).
|
||||
1. [**LLVM+CLANG**](http://releases.llvm.org) of at least version [3.8.0](http://releases.llvm.org/download.html#3.8.0); the latest stable and recommended release: [**9.0.1**](http://releases.llvm.org/download.html#9.0.1), the latest release candidate: [10.0.0-rc3](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc3).
|
||||
|
||||
2. [**CUDA**](https://developer.nvidia.com/cuda-downloads) of at least version [7.0](https://developer.nvidia.com/cuda-toolkit-70), the latest supported version is [**10.1 Update 2**](https://developer.nvidia.com/cuda-10.1-download-archive-base).
|
||||
To use the latest CUDA version [10.2](https://developer.nvidia.com/cuda-downloads) please use the latest `LLVM` release candidate: [10.0.0-rc1](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc1).
|
||||
To use the latest CUDA version [10.2](https://developer.nvidia.com/cuda-downloads) please use the latest `LLVM` release candidate: [10.0.0-rc3](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc3).
|
||||
|
||||
| **LLVM release version** | **CUDA latest supported version** | **Windows** | **Linux** |
|
||||
|:----------------------------------------------------------:|:------------------------------------------------------------------------:|:-----------:|:---------:|
|
||||
@@ -67,7 +67,7 @@ To use the latest CUDA version [10.2](https://developer.nvidia.com/cuda-download
|
||||
| [8.0.1](http://releases.llvm.org/download.html#8.0.1) | [10.0](https://developer.nvidia.com/cuda-10.0-download-archive) | - <br/> not working due to <br/> the clang's bug [38811](https://bugs.llvm.org/show_bug.cgi?id=38811) <br/>+<br/>[patch](patches/patch_for_clang_8.0.1_bug_38811.zip)*</br> | + |
|
||||
| [9.0.0](http://releases.llvm.org/download.html#9.0.0) | [10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base) | + | + |
|
||||
| [**9.0.1**](http://releases.llvm.org/download.html#9.0.1) | [**10.1**](https://developer.nvidia.com/cuda-10.1-download-archive-base) | + <br/> **LATEST STABLE RELEASE** | + <br/> **LATEST STABLE RELEASE** |
|
||||
| [10.0.0-rc1](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc1) | [10.2](https://developer.nvidia.com/cuda-downloads) | + | + |
|
||||
| [10.0.0-rc3](https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.0-rc3) | [10.2](https://developer.nvidia.com/cuda-downloads) | + | + |
|
||||
|
||||
`*` Download the patch and unpack it into your `LLVM` distributive directory; a few header files will be overwritten; rebuilding of `LLVM` is not needed.
|
||||
|
||||
@@ -158,7 +158,7 @@ Run `Visual Studio 16 2019`, open the generated `LLVM.sln`, build all, build pro
|
||||
|
||||
**LLVM 10.0.0 or newer:**
|
||||
|
||||
1. download [`LLVM project`](https://github.com/llvm/llvm-project/archive/llvmorg-10.0.0-rc1.tar.gz) sources;
|
||||
1. download [`LLVM project`](https://github.com/llvm/llvm-project/archive/llvmorg-10.0.0-rc3.tar.gz) sources;
|
||||
2. build [`LLVM project`](http://llvm.org/docs/CMake.html):
|
||||
|
||||
**Linux**:
|
||||
@@ -168,6 +168,7 @@ Run `Visual Studio 16 2019`, open the generated `LLVM.sln`, build all, build pro
|
||||
-DLLVM_SOURCE_DIR=../llvm-project \
|
||||
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \
|
||||
-DLLVM_ENABLE_PROJECTS="clang" \
|
||||
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
../llvm-project/llvm
|
||||
make -j install
|
||||
@@ -181,6 +182,7 @@ Run `Visual Studio 16 2019`, open the generated `LLVM.sln`, build all, build pro
|
||||
-DLLVM_SOURCE_DIR=../llvm-project \
|
||||
-DLLVM_TARGETS_TO_BUILD="NVPTX" \
|
||||
-DLLVM_ENABLE_PROJECTS="clang" \
|
||||
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-Thost=x64 \
|
||||
../llvm-project/llvm
|
||||
@@ -247,7 +249,7 @@ On Linux the following configurations are tested:
|
||||
|
||||
Ubuntu 14: LLVM 5.0.0 - 6.0.1, CUDA 7.0 - 9.0, cudnn-5.0.5 - cudnn-7.6.5.32
|
||||
|
||||
Ubuntu 16-18: LLVM 8.0.0 - 10.0.0-rc1, CUDA 8.0 - 10.2, cudnn-5.1.10 - cudnn-7.6.5.32
|
||||
Ubuntu 16-18: LLVM 8.0.0 - 10.0.0-rc3, CUDA 8.0 - 10.2, cudnn-5.1.10 - cudnn-7.6.5.32
|
||||
|
||||
Minimum build system requirements for the above configurations:
|
||||
|
||||
@@ -393,19 +395,19 @@ Testing Time: 3.07s
|
||||
```
|
||||
### <a name="windows"></a > hipify-clang: Windows
|
||||
|
||||
On Windows 10 the following configurations are tested:
|
||||
*Tested configurations:*
|
||||
|
||||
LLVM 5.0.0 - 5.0.2, CUDA 8.0, cudnn 5.1.10 - 7.1.4.18
|
||||
| **LLVM** | **CUDA** | **cuDNN** | **Visual Studio** | **cmake** | **Python** |
|
||||
|:--------------:|---------:|--------------------:|--------------------------:|----------:|-----------:|
|
||||
| 5.0.0 - 5.0.2 | 8.0 | 5.1.10 - 7.1.4.18 | 2017.15.5.2 | 3.5.1 | 3.6.4 |
|
||||
| 6.0.0 - 6.0.1 | 9.0 | 7.0.5.15 - 7.6.5.32 | 2017.15.5.5 | 3.6.0 | 3.7.2 |
|
||||
| 7.0.0 - 7.1.0 | 9.2 | 7.6.5.32 | 2017.15.9.11 | 3.13.3 | 3.7.3 |
|
||||
| 8.0.0 - 8.0.1 | 10.0 | 7.6.5.32 | 2017.15.9.15 | 3.14.2 | 3.7.4 |
|
||||
| 9.0.0 - 9.0.1 | 10.1 | 7.6.5.32 | 2017.15.9.20, 2019.16.4.5 | 3.16.4 | 3.8.0 |
|
||||
| 10.0.0-rc1-rc3 | 10.2 | 7.6.5.32 | 2017.15.9.20, 2019.16.4.5 | 3.16.4 | 3.8.1 |
|
||||
| 11.0.0git | 10.2 | 7.6.5.32 | 2017.15.9.20, 2019.16.4.5 | 3.16.5 | 3.8.2 |
|
||||
|
||||
LLVM 6.0.0 - 6.0.1, CUDA 9.0, cudnn 7.0.5.15 - 7.6.5.32
|
||||
|
||||
LLVM 7.0.0 - 10.0.0-rc1, CUDA 7.5 - 10.2, cudnn 7.0.5.15 - 7.6.5.32
|
||||
|
||||
Build system requirements for the latest stable configuration LLVM 9.0.1/CUDA 10.1 Update 2:
|
||||
|
||||
Python 3.6.0 - 3.8.1, cmake 3.5.1 - 3.16.3, Visual Studio 2017 (15.5.2) - 2019 (16.4.4).
|
||||
|
||||
Here is an example of building `hipify-clang` with testing support on `Windows 10` by `Visual Studio 16 2019`:
|
||||
*Building with testing support on `Windows 10` by `Visual Studio 16 2019`:*
|
||||
|
||||
```shell
|
||||
cmake
|
||||
@@ -429,7 +431,7 @@ cmake
|
||||
-- - CMake module path: F:/LLVM/9.0.1/dist/lib/cmake/llvm
|
||||
-- - Include path : F:/LLVM/9.0.1/dist/include
|
||||
-- - Binary path : F:/LLVM/9.0.1/dist/bin
|
||||
-- Found PythonInterp: C:/Program Files/Python38/python.exe (found suitable version "3.8.1", minimum required is "3.6")
|
||||
-- Found PythonInterp: C:/Program Files/Python38/python.exe (found suitable version "3.8.2", minimum required is "3.6")
|
||||
-- Found lit: C:/Program Files/Python38/Scripts/lit.exe
|
||||
-- Found FileCheck: F:/LLVM/9.0.1/dist/bin/FileCheck.exe
|
||||
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1 (found version "10.1")
|
||||
|
||||
@@ -545,9 +545,9 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_FUNCTION_MAP{
|
||||
|
||||
// 5.21. Occupancy
|
||||
// cudaOccupancyMaxActiveBlocksPerMultiprocessor
|
||||
{"cuOccupancyMaxActiveBlocksPerMultiprocessor", {"hipOccupancyMaxActiveBlocksPerMultiprocessor", "", CONV_OCCUPANCY, API_DRIVER}},
|
||||
{"cuOccupancyMaxActiveBlocksPerMultiprocessor", {"hipDrvOccupancyMaxActiveBlocksPerMultiprocessor", "", CONV_OCCUPANCY, API_DRIVER}},
|
||||
// cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
|
||||
{"cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", {"hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", "", CONV_OCCUPANCY, API_DRIVER}},
|
||||
{"cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", {"hipDrvOccupancyMaxActiveBlocksPerMultiprocessorWithFlags", "", CONV_OCCUPANCY, API_DRIVER}},
|
||||
// cudaOccupancyMaxPotentialBlockSize
|
||||
{"cuOccupancyMaxPotentialBlockSize", {"hipOccupancyMaxPotentialBlockSize", "", CONV_OCCUPANCY, API_DRIVER}},
|
||||
// cudaOccupancyMaxPotentialBlockSizeWithFlags
|
||||
|
||||
@@ -1047,7 +1047,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP{
|
||||
{"CUoccupancy_flags_enum", {"hipOccupancyFlags", "", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
|
||||
// CUoccupancy_flags enum values
|
||||
// cudaOccupancyDefault
|
||||
{"CU_OCCUPANCY_DEFAULT", {"hipOccupancyDefault", "", CONV_NUMERIC_LITERAL, API_DRIVER, HIP_UNSUPPORTED}}, // 0x00
|
||||
{"CU_OCCUPANCY_DEFAULT", {"hipOccupancyDefault", "", CONV_NUMERIC_LITERAL, API_DRIVER}}, // 0x00
|
||||
// cudaOccupancyDisableCachingOverride
|
||||
{"CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE", {"hipOccupancyDisableCachingOverride", "", CONV_NUMERIC_LITERAL, API_DRIVER, HIP_UNSUPPORTED}}, // 0x01
|
||||
|
||||
@@ -1284,6 +1284,8 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP{
|
||||
{"CUDA_ERROR_INVALID_PC", {"hipErrorInvalidPc", "", CONV_NUMERIC_LITERAL, API_DRIVER, HIP_UNSUPPORTED}}, // 718
|
||||
// cudaErrorLaunchFailure
|
||||
{"CUDA_ERROR_LAUNCH_FAILED", {"hipErrorLaunchFailure", "", CONV_NUMERIC_LITERAL, API_DRIVER}}, // 719
|
||||
// cudaErrorCooperativeLaunchTooLarge
|
||||
{"CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE", {"hipErrorCooperativeLaunchTooLarge", "", CONV_NUMERIC_LITERAL, API_DRIVER}}, // 720
|
||||
// cudaErrorNotPermitted
|
||||
{"CUDA_ERROR_NOT_PERMITTED", {"hipErrorNotPermitted", "", CONV_NUMERIC_LITERAL, API_DRIVER, HIP_UNSUPPORTED}}, // 800
|
||||
// cudaErrorNotSupported
|
||||
@@ -1598,9 +1600,9 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP{
|
||||
// cudaArrayColorAttachment
|
||||
{"CUDA_ARRAY3D_COLOR_ATTACHMENT", {"hipArrayColorAttachment", "", CONV_DEFINE, API_DRIVER, HIP_UNSUPPORTED}}, // 0x20
|
||||
// cudaCooperativeLaunchMultiDeviceNoPreSync
|
||||
{"CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC", {"hipCooperativeLaunchMultiDeviceNoPreSync", "", CONV_DEFINE, API_DRIVER, HIP_UNSUPPORTED}}, // 0x01
|
||||
{"CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC", {"hipCooperativeLaunchMultiDeviceNoPreSync", "", CONV_DEFINE, API_DRIVER}}, // 0x01
|
||||
// cudaCooperativeLaunchMultiDeviceNoPostSync
|
||||
{"CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC", {"hipCooperativeLaunchMultiDeviceNoPostSync", "", CONV_DEFINE, API_DRIVER, HIP_UNSUPPORTED}}, // 0x02
|
||||
{"CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC", {"hipCooperativeLaunchMultiDeviceNoPostSync", "", CONV_DEFINE, API_DRIVER}}, // 0x02
|
||||
// cudaExternalMemoryDedicated
|
||||
{"CUDA_EXTERNAL_MEMORY_DEDICATED", {"hipExternalMemoryDedicated", "", CONV_DEFINE, API_DRIVER, HIP_UNSUPPORTED}}, // 0x1
|
||||
// cudaExternalSemaphoreSignalSkipNvSciBufMemSync
|
||||
|
||||
@@ -787,8 +787,8 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_TYPE_NAME_MAP {
|
||||
{"cudaErrorInvalidPc", {"hipErrorInvalidPc", "", CONV_NUMERIC_LITERAL, API_RUNTIME, HIP_UNSUPPORTED}}, // 718
|
||||
// CUDA_ERROR_LAUNCH_FAILED
|
||||
{"cudaErrorLaunchFailure", {"hipErrorLaunchFailure", "", CONV_NUMERIC_LITERAL, API_RUNTIME}}, // 719
|
||||
// no analogue
|
||||
{"cudaErrorCooperativeLaunchTooLarge", {"hipErrorCooperativeLaunchTooLarge", "", CONV_NUMERIC_LITERAL, API_RUNTIME, HIP_UNSUPPORTED}}, // 720
|
||||
// CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE
|
||||
{"cudaErrorCooperativeLaunchTooLarge", {"hipErrorCooperativeLaunchTooLarge", "", CONV_NUMERIC_LITERAL, API_RUNTIME}}, // 720
|
||||
// CUDA_ERROR_NOT_PERMITTED
|
||||
{"cudaErrorNotPermitted", {"hipErrorNotPermitted", "", CONV_NUMERIC_LITERAL, API_RUNTIME, HIP_UNSUPPORTED}}, // 800
|
||||
// CUDA_ERROR_NOT_SUPPORTED
|
||||
@@ -1327,9 +1327,9 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_TYPE_NAME_MAP {
|
||||
// CUDA_ARRAY3D_COLOR_ATTACHMENT
|
||||
{"cudaArrayColorAttachment", {"hipArrayColorAttachment", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // 0x20
|
||||
// CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_PRE_LAUNCH_SYNC
|
||||
{"cudaCooperativeLaunchMultiDeviceNoPreSync", {"hipCooperativeLaunchMultiDeviceNoPreSync", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // 0x01
|
||||
{"cudaCooperativeLaunchMultiDeviceNoPreSync", {"hipCooperativeLaunchMultiDeviceNoPreSync", "", CONV_DEFINE, API_RUNTIME}}, // 0x01
|
||||
// CUDA_COOPERATIVE_LAUNCH_MULTI_DEVICE_NO_POST_LAUNCH_SYNC
|
||||
{"cudaCooperativeLaunchMultiDeviceNoPostSync", {"hipCooperativeLaunchMultiDeviceNoPostSync", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // 0x02
|
||||
{"cudaCooperativeLaunchMultiDeviceNoPostSync", {"hipCooperativeLaunchMultiDeviceNoPostSync", "", CONV_DEFINE, API_RUNTIME}}, // 0x02
|
||||
// CU_DEVICE_CPU ((CUdevice)-1)
|
||||
{"cudaCpuDeviceId", {"hipCpuDeviceId", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // ((int)-1)
|
||||
// CU_DEVICE_INVALID ((CUdevice)-2)
|
||||
@@ -1412,7 +1412,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_TYPE_NAME_MAP {
|
||||
// no analogue
|
||||
{"cudaTextureTypeCubemapLayered", {"hipTextureTypeCubemapLayered", "", CONV_DEFINE, API_RUNTIME}}, // 0xFC
|
||||
// CU_OCCUPANCY_DEFAULT
|
||||
{"cudaOccupancyDefault", {"hipOccupancyDefault", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // 0x00
|
||||
{"cudaOccupancyDefault", {"hipOccupancyDefault", "", CONV_DEFINE, API_RUNTIME}}, // 0x00
|
||||
// CU_OCCUPANCY_DISABLE_CACHING_OVERRIDE
|
||||
{"cudaOccupancyDisableCachingOverride", {"hipOccupancyDisableCachingOverride", "", CONV_DEFINE, API_RUNTIME, HIP_UNSUPPORTED}}, // 0x01
|
||||
// CU_STREAM_DEFAULT
|
||||
|
||||
@@ -29,8 +29,14 @@ THE SOFTWARE.
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#if __HIP_VDI__
|
||||
extern "C" {
|
||||
#endif
|
||||
HIP_PUBLIC_API
|
||||
hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f);
|
||||
#if __HIP_VDI__
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline hipChannelFormatDesc hipCreateChannelDescHalf() {
|
||||
int e = (int)sizeof(unsigned short) * 8;
|
||||
|
||||
@@ -31,9 +31,11 @@ THE SOFTWARE.
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <unordered_set>
|
||||
namespace hip_impl {
|
||||
|
||||
#if !defined(DISABLE_REDUCED_GPU_BLOB_COPY)
|
||||
std::unordered_set<std::string>& get_all_gpuarch();
|
||||
#endif
|
||||
inline
|
||||
std::string transmogrify_triple(const std::string& triple)
|
||||
{
|
||||
@@ -43,7 +45,6 @@ std::string transmogrify_triple(const std::string& triple)
|
||||
if (triple.find(old_prefix) == 0) {
|
||||
return new_prefix + triple.substr(sizeof(old_prefix) - 1);
|
||||
}
|
||||
|
||||
return (triple.find(new_prefix) == 0) ? triple : "";
|
||||
}
|
||||
|
||||
@@ -114,9 +115,7 @@ class Bundled_code_header {
|
||||
friend inline bool read(RandomAccessIterator f, RandomAccessIterator l,
|
||||
Bundled_code_header& x) {
|
||||
if (f == l) return false;
|
||||
|
||||
std::copy_n(f, sizeof(x.header_.cbuf_), x.header_.cbuf_);
|
||||
|
||||
if (valid(x)) {
|
||||
x.bundles_.resize(x.header_.bundle_cnt_);
|
||||
|
||||
@@ -126,11 +125,16 @@ class Bundled_code_header {
|
||||
it += sizeof(y.header.cbuf);
|
||||
|
||||
y.triple.assign(it, it + y.header.triple_sz);
|
||||
|
||||
#ifdef DISABLE_REDUCED_GPU_BLOB_COPY
|
||||
std::copy_n(f + y.header.offset, y.header.bundle_sz, std::back_inserter(y.blob));
|
||||
|
||||
#else
|
||||
auto& gpuArch = get_all_gpuarch();
|
||||
auto itgpuArch = std::find(gpuArch.begin(),gpuArch.end(),y.triple);
|
||||
if (itgpuArch != gpuArch.end()){
|
||||
std::copy_n(f + y.header.offset, y.header.bundle_sz, std::back_inserter(y.blob));
|
||||
}
|
||||
#endif
|
||||
it += y.header.triple_sz;
|
||||
|
||||
x.bundled_code_size = std::max(x.bundled_code_size,
|
||||
y.header.offset + y.header.bundle_sz);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,21 @@ THE SOFTWARE.
|
||||
#include <hip/hip_vector_types.h>
|
||||
#include <hip/hcc_detail/device_library_decls.h>
|
||||
#include <hip/hcc_detail/llvm_intrinsics.h>
|
||||
|
||||
#if __HIP_CLANG_ONLY__ && __HIP_VDI__
|
||||
extern "C" __device__ int printf(const char *fmt, ...);
|
||||
#else
|
||||
#if HC_FEATURE_PRINTF
|
||||
template <typename... All>
|
||||
static inline __device__ void printf(const char* format, All... all) {
|
||||
hc::printf(format, all...);
|
||||
}
|
||||
#else
|
||||
template <typename... All>
|
||||
static inline __device__ void printf(const char* format, All... all) {}
|
||||
#endif // HC_FEATURE_PRINTF
|
||||
#endif // __HIP_CLANG_ONLY__ && __HIP_VDI__
|
||||
|
||||
/*
|
||||
Integer Intrinsics
|
||||
*/
|
||||
@@ -319,6 +334,41 @@ double __shfl(double var, int src_lane, int width = warpSize) {
|
||||
double tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long __shfl(long var, int src_lane, int width = warpSize)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
static_assert(sizeof(long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long) == sizeof(uint64_t), "");
|
||||
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl(tmp[0], src_lane, width);
|
||||
tmp[1] = __shfl(tmp[1], src_lane, width);
|
||||
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
#else
|
||||
static_assert(sizeof(long) == sizeof(int), "");
|
||||
return static_cast<long>(__shfl(static_cast<int>(var), src_lane, width));
|
||||
#endif
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long long __shfl(long long var, int src_lane, int width = warpSize)
|
||||
{
|
||||
static_assert(sizeof(long long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long long) == sizeof(uint64_t), "");
|
||||
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl(tmp[0], src_lane, width);
|
||||
tmp[1] = __shfl(tmp[1], src_lane, width);
|
||||
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
|
||||
__device__
|
||||
inline
|
||||
@@ -356,6 +406,39 @@ double __shfl_up(double var, unsigned int lane_delta, int width = warpSize) {
|
||||
double tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long __shfl_up(long var, unsigned int lane_delta, int width = warpSize)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
static_assert(sizeof(long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long) == sizeof(uint64_t), "");
|
||||
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_up(tmp[0], lane_delta, width);
|
||||
tmp[1] = __shfl_up(tmp[1], lane_delta, width);
|
||||
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
#else
|
||||
static_assert(sizeof(long) == sizeof(int), "");
|
||||
return static_cast<long>(__shfl_up(static_cast<int>(var), lane_delta, width));
|
||||
#endif
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long long __shfl_up(long long var, unsigned int lane_delta, int width = warpSize)
|
||||
{
|
||||
static_assert(sizeof(long long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long long) == sizeof(uint64_t), "");
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_up(tmp[0], lane_delta, width);
|
||||
tmp[1] = __shfl_up(tmp[1], lane_delta, width);
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
|
||||
__device__
|
||||
inline
|
||||
@@ -393,6 +476,39 @@ double __shfl_down(double var, unsigned int lane_delta, int width = warpSize) {
|
||||
double tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long __shfl_down(long var, unsigned int lane_delta, int width = warpSize)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
static_assert(sizeof(long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long) == sizeof(uint64_t), "");
|
||||
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_down(tmp[0], lane_delta, width);
|
||||
tmp[1] = __shfl_down(tmp[1], lane_delta, width);
|
||||
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
#else
|
||||
static_assert(sizeof(long) == sizeof(int), "");
|
||||
return static_cast<long>(__shfl_down(static_cast<int>(var), lane_delta, width));
|
||||
#endif
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long long __shfl_down(long long var, unsigned int lane_delta, int width = warpSize)
|
||||
{
|
||||
static_assert(sizeof(long long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long long) == sizeof(uint64_t), "");
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_down(tmp[0], lane_delta, width);
|
||||
tmp[1] = __shfl_down(tmp[1], lane_delta, width);
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
|
||||
__device__
|
||||
inline
|
||||
@@ -430,6 +546,39 @@ double __shfl_xor(double var, int lane_mask, int width = warpSize) {
|
||||
double tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long __shfl_xor(long var, int lane_mask, int width = warpSize)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
static_assert(sizeof(long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long) == sizeof(uint64_t), "");
|
||||
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_xor(tmp[0], lane_mask, width);
|
||||
tmp[1] = __shfl_xor(tmp[1], lane_mask, width);
|
||||
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
#else
|
||||
static_assert(sizeof(long) == sizeof(int), "");
|
||||
return static_cast<long>(__shfl_down(static_cast<int>(var), lane_mask, width));
|
||||
#endif
|
||||
}
|
||||
__device__
|
||||
inline
|
||||
long long __shfl_xor(long long var, int lane_mask, int width = warpSize)
|
||||
{
|
||||
static_assert(sizeof(long long) == 2 * sizeof(int), "");
|
||||
static_assert(sizeof(long long) == sizeof(uint64_t), "");
|
||||
int tmp[2]; __builtin_memcpy(tmp, &var, sizeof(tmp));
|
||||
tmp[0] = __shfl_xor(tmp[0], lane_mask, width);
|
||||
tmp[1] = __shfl_xor(tmp[1], lane_mask, width);
|
||||
uint64_t tmp0 = (static_cast<uint64_t>(tmp[1]) << 32ull) | static_cast<uint32_t>(tmp[0]);
|
||||
long long tmp1; __builtin_memcpy(&tmp1, &tmp0, sizeof(tmp0));
|
||||
return tmp1;
|
||||
}
|
||||
|
||||
#define MASK1 0x00ff00ff
|
||||
#define MASK2 0xff00ff00
|
||||
|
||||
@@ -135,6 +135,47 @@ typedef enum hipResourceType {
|
||||
hipResourceTypePitch2D = 0x03
|
||||
}hipResourceType;
|
||||
|
||||
typedef enum HIPresourcetype_enum {
|
||||
HIP_RESOURCE_TYPE_ARRAY = 0x00, /**< Array resoure */
|
||||
HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01, /**< Mipmapped array resource */
|
||||
HIP_RESOURCE_TYPE_LINEAR = 0x02, /**< Linear resource */
|
||||
HIP_RESOURCE_TYPE_PITCH2D = 0x03 /**< Pitch 2D resource */
|
||||
} HIPresourcetype;
|
||||
|
||||
/**
|
||||
* hip address modes
|
||||
*/
|
||||
typedef enum HIPaddress_mode_enum {
|
||||
HIP_TR_ADDRESS_MODE_WRAP = 0,
|
||||
HIP_TR_ADDRESS_MODE_CLAMP = 1,
|
||||
HIP_TR_ADDRESS_MODE_MIRROR = 2,
|
||||
HIP_TR_ADDRESS_MODE_BORDER = 3
|
||||
} HIPaddress_mode;
|
||||
|
||||
/**
|
||||
* hip filter modes
|
||||
*/
|
||||
typedef enum HIPfilter_mode_enum {
|
||||
HIP_TR_FILTER_MODE_POINT = 0,
|
||||
HIP_TR_FILTER_MODE_LINEAR = 1
|
||||
} HIPfilter_mode;
|
||||
|
||||
/**
|
||||
* Texture descriptor
|
||||
*/
|
||||
typedef struct HIP_TEXTURE_DESC_st {
|
||||
HIPaddress_mode addressMode[3]; /**< Address modes */
|
||||
HIPfilter_mode filterMode; /**< Filter mode */
|
||||
unsigned int flags; /**< Flags */
|
||||
unsigned int maxAnisotropy; /**< Maximum anisotropy ratio */
|
||||
HIPfilter_mode mipmapFilterMode; /**< Mipmap filter mode */
|
||||
float mipmapLevelBias; /**< Mipmap level bias */
|
||||
float minMipmapLevelClamp; /**< Mipmap minimum level clamp */
|
||||
float maxMipmapLevelClamp; /**< Mipmap maximum level clamp */
|
||||
float borderColor[4]; /**< Border Color */
|
||||
int reserved[12];
|
||||
} HIP_TEXTURE_DESC;
|
||||
|
||||
/**
|
||||
* hip texture resource view formats
|
||||
*/
|
||||
@@ -176,6 +217,45 @@ typedef enum hipResourceViewFormat {
|
||||
hipResViewFormatUnsignedBlockCompressed7 = 0x22
|
||||
}hipResourceViewFormat;
|
||||
|
||||
typedef enum HIPresourceViewFormat_enum
|
||||
{
|
||||
HIP_RES_VIEW_FORMAT_NONE = 0x00, /**< No resource view format (use underlying resource format) */
|
||||
HIP_RES_VIEW_FORMAT_UINT_1X8 = 0x01, /**< 1 channel unsigned 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_2X8 = 0x02, /**< 2 channel unsigned 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_4X8 = 0x03, /**< 4 channel unsigned 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_1X8 = 0x04, /**< 1 channel signed 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_2X8 = 0x05, /**< 2 channel signed 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_4X8 = 0x06, /**< 4 channel signed 8-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_1X16 = 0x07, /**< 1 channel unsigned 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_2X16 = 0x08, /**< 2 channel unsigned 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_4X16 = 0x09, /**< 4 channel unsigned 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_1X16 = 0x0a, /**< 1 channel signed 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_2X16 = 0x0b, /**< 2 channel signed 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_4X16 = 0x0c, /**< 4 channel signed 16-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_1X32 = 0x0d, /**< 1 channel unsigned 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_2X32 = 0x0e, /**< 2 channel unsigned 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_UINT_4X32 = 0x0f, /**< 4 channel unsigned 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_1X32 = 0x10, /**< 1 channel signed 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_2X32 = 0x11, /**< 2 channel signed 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_SINT_4X32 = 0x12, /**< 4 channel signed 32-bit integers */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13, /**< 1 channel 16-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14, /**< 2 channel 16-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15, /**< 4 channel 16-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16, /**< 1 channel 32-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17, /**< 2 channel 32-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18, /**< 4 channel 32-bit floating point */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19, /**< Block compressed 1 */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a, /**< Block compressed 2 */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b, /**< Block compressed 3 */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c, /**< Block compressed 4 unsigned */
|
||||
HIP_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d, /**< Block compressed 4 signed */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e, /**< Block compressed 5 unsigned */
|
||||
HIP_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f, /**< Block compressed 5 signed */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20, /**< Block compressed 6 unsigned half-float */
|
||||
HIP_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21, /**< Block compressed 6 signed half-float */
|
||||
HIP_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22 /**< Block compressed 7 */
|
||||
} HIPresourceViewFormat;
|
||||
|
||||
/**
|
||||
* HIP resource descriptor
|
||||
*/
|
||||
@@ -204,6 +284,39 @@ typedef struct hipResourceDesc {
|
||||
} res;
|
||||
}hipResourceDesc;
|
||||
|
||||
typedef struct HIP_RESOURCE_DESC_st
|
||||
{
|
||||
HIPresourcetype resType; /**< Resource type */
|
||||
|
||||
union {
|
||||
struct {
|
||||
hipArray_t hArray; /**< HIP array */
|
||||
} array;
|
||||
struct {
|
||||
hipMipmappedArray_t hMipmappedArray; /**< HIP mipmapped array */
|
||||
} mipmap;
|
||||
struct {
|
||||
hipDeviceptr_t devPtr; /**< Device pointer */
|
||||
hipArray_Format format; /**< Array format */
|
||||
unsigned int numChannels; /**< Channels per array element */
|
||||
size_t sizeInBytes; /**< Size in bytes */
|
||||
} linear;
|
||||
struct {
|
||||
hipDeviceptr_t devPtr; /**< Device pointer */
|
||||
hipArray_Format format; /**< Array format */
|
||||
unsigned int numChannels; /**< Channels per array element */
|
||||
size_t width; /**< Width of the array in elements */
|
||||
size_t height; /**< Height of the array in elements */
|
||||
size_t pitchInBytes; /**< Pitch between two rows in bytes */
|
||||
} pitch2D;
|
||||
struct {
|
||||
int reserved[32];
|
||||
} reserved;
|
||||
} res;
|
||||
|
||||
unsigned int flags; /**< Flags (must be zero) */
|
||||
} HIP_RESOURCE_DESC;
|
||||
|
||||
/**
|
||||
* hip resource view descriptor
|
||||
*/
|
||||
@@ -218,6 +331,22 @@ struct hipResourceViewDesc {
|
||||
unsigned int lastLayer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resource view descriptor
|
||||
*/
|
||||
typedef struct HIP_RESOURCE_VIEW_DESC_st
|
||||
{
|
||||
HIPresourceViewFormat format; /**< Resource view format */
|
||||
size_t width; /**< Width of the resource view */
|
||||
size_t height; /**< Height of the resource view */
|
||||
size_t depth; /**< Depth of the resource view */
|
||||
unsigned int firstMipmapLevel; /**< First defined mipmap level */
|
||||
unsigned int lastMipmapLevel; /**< Last defined mipmap level */
|
||||
unsigned int firstLayer; /**< First layer index */
|
||||
unsigned int lastLayer; /**< Last layer index */
|
||||
unsigned int reserved[16];
|
||||
} HIP_RESOURCE_VIEW_DESC;
|
||||
|
||||
/**
|
||||
* Memory copy types
|
||||
*
|
||||
@@ -255,38 +384,38 @@ typedef struct hipMemcpy3DParms {
|
||||
hipArray_t srcArray;
|
||||
struct hipPos srcPos;
|
||||
struct hipPitchedPtr srcPtr;
|
||||
|
||||
hipArray_t dstArray;
|
||||
struct hipPos dstPos;
|
||||
struct hipPitchedPtr dstPtr;
|
||||
|
||||
struct hipExtent extent;
|
||||
enum hipMemcpyKind kind;
|
||||
} hipMemcpy3DParms;
|
||||
|
||||
size_t Depth;
|
||||
size_t Height;
|
||||
size_t WidthInBytes;
|
||||
hipDeviceptr_t dstDevice;
|
||||
size_t dstHeight;
|
||||
void* dstHost;
|
||||
size_t dstLOD;
|
||||
hipMemoryType dstMemoryType;
|
||||
size_t dstPitch;
|
||||
size_t dstXInBytes;
|
||||
size_t dstY;
|
||||
size_t dstZ;
|
||||
void* reserved0;
|
||||
void* reserved1;
|
||||
hipDeviceptr_t srcDevice;
|
||||
size_t srcHeight;
|
||||
const void* srcHost;
|
||||
size_t srcLOD;
|
||||
hipMemoryType srcMemoryType;
|
||||
size_t srcPitch;
|
||||
size_t srcXInBytes;
|
||||
size_t srcY;
|
||||
size_t srcZ;
|
||||
}hipMemcpy3DParms;
|
||||
typedef struct HIP_MEMCPY3D {
|
||||
unsigned int srcXInBytes;
|
||||
unsigned int srcY;
|
||||
unsigned int srcZ;
|
||||
unsigned int srcLOD;
|
||||
hipMemoryType srcMemoryType;
|
||||
const void* srcHost;
|
||||
hipDeviceptr_t srcDevice;
|
||||
hipArray_t srcArray;
|
||||
unsigned int srcPitch;
|
||||
unsigned int srcHeight;
|
||||
unsigned int dstXInBytes;
|
||||
unsigned int dstY;
|
||||
unsigned int dstZ;
|
||||
unsigned int dstLOD;
|
||||
hipMemoryType dstMemoryType;
|
||||
void* dstHost;
|
||||
hipDeviceptr_t dstDevice;
|
||||
hipArray_t dstArray;
|
||||
unsigned int dstPitch;
|
||||
unsigned int dstHeight;
|
||||
unsigned int WidthInBytes;
|
||||
unsigned int Height;
|
||||
unsigned int Depth;
|
||||
} HIP_MEMCPY3D;
|
||||
|
||||
static inline struct hipPitchedPtr make_hipPitchedPtr(void* d, size_t p, size_t xsz,
|
||||
size_t ysz) {
|
||||
|
||||
@@ -189,16 +189,6 @@ void hipLaunchKernelGGL(F kernel, const dim3& numBlocks, const dim3& dimBlocks,
|
||||
stream, &config[0]);
|
||||
}
|
||||
|
||||
inline
|
||||
__attribute__((visibility("hidden")))
|
||||
hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList,
|
||||
int numDevices, unsigned int flags) {
|
||||
hip_impl::hip_init();
|
||||
auto& ps = hip_impl::get_program_state();
|
||||
return ihipExtLaunchMultiKernelMultiDevice(launchParamsList, numDevices, flags, ps);
|
||||
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
inline
|
||||
__attribute__((visibility("hidden")))
|
||||
|
||||
@@ -103,9 +103,12 @@ extern int HIP_TRACE_API;
|
||||
#include <hip/hcc_detail/host_defines.h>
|
||||
#include <hip/hcc_detail/device_functions.h>
|
||||
#include <hip/hcc_detail/surface_functions.h>
|
||||
#include <hip/hcc_detail/texture_functions.h>
|
||||
#if __HCC__
|
||||
#include <hip/hcc_detail/math_functions.h>
|
||||
#include <hip/hcc_detail/texture_functions.h>
|
||||
#else
|
||||
#include <hip/hcc_detail/texture_fetch_functions.h>
|
||||
#include <hip/hcc_detail/texture_indirect_functions.h>
|
||||
#endif
|
||||
// TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define.
|
||||
#if defined(__KALMAR_ACCELERATOR__) && !defined(__HCC_ACCELERATOR__)
|
||||
@@ -311,16 +314,6 @@ extern "C" __device__ void* __hip_free(void* ptr);
|
||||
static inline __device__ void* malloc(size_t size) { return __hip_malloc(size); }
|
||||
static inline __device__ void* free(void* ptr) { return __hip_free(ptr); }
|
||||
|
||||
#if defined(__HCC_ACCELERATOR__) && defined(HC_FEATURE_PRINTF)
|
||||
template <typename... All>
|
||||
static inline __device__ void printf(const char* format, All... all) {
|
||||
hc::printf(format, all...);
|
||||
}
|
||||
#elif defined(__HCC_ACCELERATOR__) || __HIP__
|
||||
template <typename... All>
|
||||
static inline __device__ void printf(const char* format, All... all) {}
|
||||
#endif
|
||||
|
||||
#endif //__HCC_OR_HIP_CLANG__
|
||||
|
||||
#ifdef __HCC__
|
||||
@@ -386,7 +379,7 @@ extern void ihipPostLaunchKernel(const char* kernelName, hipStream_t stream, gri
|
||||
#elif defined(__clang__) && defined(__HIP__)
|
||||
|
||||
#define HIP_KERNEL_NAME(...) __VA_ARGS__
|
||||
#define HIP_SYMBOL(X) #X
|
||||
#define HIP_SYMBOL(X) X
|
||||
|
||||
typedef int hipLaunchParm;
|
||||
|
||||
|
||||
@@ -212,6 +212,11 @@ enum hipLimit_t {
|
||||
#define hipArrayCubemap 0x04
|
||||
#define hipArrayTextureGather 0x08
|
||||
|
||||
#define hipOccupancyDefault 0x00
|
||||
|
||||
#define hipCooperativeLaunchMultiDeviceNoPreSync 0x01
|
||||
#define hipCooperativeLaunchMultiDeviceNoPostSync 0x02
|
||||
|
||||
/*
|
||||
* @brief hipJitOption
|
||||
* @enum
|
||||
@@ -1483,18 +1488,18 @@ hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t siz
|
||||
hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes,
|
||||
hipModule_t hmod, const char* name);
|
||||
|
||||
hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName);
|
||||
hipError_t hipGetSymbolSize(size_t* size, const void* symbolName);
|
||||
hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src,
|
||||
hipError_t hipGetSymbolAddress(void** devPtr, const void* symbol);
|
||||
hipError_t hipGetSymbolSize(size_t* size, const void* symbol);
|
||||
hipError_t hipMemcpyToSymbol(const void* symbol, const void* src,
|
||||
size_t sizeBytes, size_t offset __dparm(0),
|
||||
hipMemcpyKind kind __dparm(hipMemcpyHostToDevice));
|
||||
hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src,
|
||||
hipError_t hipMemcpyToSymbolAsync(const void* symbol, const void* src,
|
||||
size_t sizeBytes, size_t offset,
|
||||
hipMemcpyKind kind, hipStream_t stream __dparm(0));
|
||||
hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName,
|
||||
hipError_t hipMemcpyFromSymbol(void* dst, const void* symbol,
|
||||
size_t sizeBytes, size_t offset __dparm(0),
|
||||
hipMemcpyKind kind __dparm(hipMemcpyDeviceToHost));
|
||||
hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName,
|
||||
hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbol,
|
||||
size_t sizeBytes, size_t offset,
|
||||
hipMemcpyKind kind,
|
||||
hipStream_t stream __dparm(0));
|
||||
@@ -1934,6 +1939,15 @@ hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent);
|
||||
*/
|
||||
hipError_t hipFreeArray(hipArray* array);
|
||||
|
||||
/**
|
||||
* @brief Frees a mipmapped array on the device
|
||||
*
|
||||
* @param[in] mipmappedArray - Pointer to mipmapped array to free
|
||||
*
|
||||
* @return #hipSuccess, #hipErrorInvalidValue
|
||||
*/
|
||||
hipError_t hipFreeMipmappedArray(hipMipmappedArray_t mipmappedArray);
|
||||
|
||||
/**
|
||||
* @brief Allocate an array on the device.
|
||||
*
|
||||
@@ -1948,6 +1962,39 @@ hipError_t hipFreeArray(hipArray* array);
|
||||
|
||||
hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* desc,
|
||||
struct hipExtent extent, unsigned int flags);
|
||||
|
||||
/**
|
||||
* @brief Allocate a mipmapped array on the device
|
||||
*
|
||||
* @param[out] mipmappedArray - Pointer to allocated mipmapped array in device memory
|
||||
* @param[in] desc - Requested channel format
|
||||
* @param[in] extent - Requested allocation size (width field in elements)
|
||||
* @param[in] numLevels - Number of mipmap levels to allocate
|
||||
* @param[in] flags - Flags for extensions
|
||||
*
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryAllocation
|
||||
*/
|
||||
hipError_t hipMallocMipmappedArray(
|
||||
hipMipmappedArray_t *mipmappedArray,
|
||||
const struct hipChannelFormatDesc* desc,
|
||||
struct hipExtent extent,
|
||||
unsigned int numLevels,
|
||||
unsigned int flags __dparm(0));
|
||||
|
||||
/**
|
||||
* @brief Gets a mipmap level of a HIP mipmapped array
|
||||
*
|
||||
* @param[out] levelArray - Returned mipmap level HIP array
|
||||
* @param[in] mipmappedArray - HIP mipmapped array
|
||||
* @param[in] level - Mipmap level
|
||||
*
|
||||
* @return #hipSuccess, #hipErrorInvalidValue
|
||||
*/
|
||||
hipError_t hipGetMipmappedArrayLevel(
|
||||
hipArray_t *levelArray,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
unsigned int level);
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device.
|
||||
*
|
||||
@@ -2160,6 +2207,31 @@ hipError_t hipMemcpy3D(const struct hipMemcpy3DParms* p);
|
||||
*/
|
||||
hipError_t hipMemcpy3DAsync(const struct hipMemcpy3DParms* p, hipStream_t stream __dparm(0));
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device.
|
||||
*
|
||||
* @param[in] pCopy 3D memory copy parameters
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue,
|
||||
* #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
|
||||
*
|
||||
* @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol,
|
||||
* hipMemcpyAsync
|
||||
*/
|
||||
hipError_t hipDrvMemcpy3D(const HIP_MEMCPY3D* pCopy);
|
||||
|
||||
/**
|
||||
* @brief Copies data between host and device asynchronously.
|
||||
*
|
||||
* @param[in] pCopy 3D memory copy parameters
|
||||
* @param[in] stream Stream to use
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidPitchValue,
|
||||
* #hipErrorInvalidDevicePointer, #hipErrorInvalidMemcpyDirection
|
||||
*
|
||||
* @see hipMemcpy, hipMemcpy2DToArray, hipMemcpy2D, hipMemcpyFromArray, hipMemcpyToSymbol,
|
||||
* hipMemcpyAsync
|
||||
*/
|
||||
hipError_t hipDrvMemcpy3DAsync(const HIP_MEMCPY3D* pCopy, hipStream_t stream);
|
||||
|
||||
// doxygen end Memory
|
||||
/**
|
||||
* @}
|
||||
@@ -2903,7 +2975,7 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigne
|
||||
* @param [in] stream Stream where the kernel should be dispatched. May be 0, in which case th
|
||||
* default stream is used with associated synchronization rules.
|
||||
*
|
||||
* @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue
|
||||
* @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue, hipErrorCooperativeLaunchTooLarge
|
||||
*/
|
||||
hipError_t hipLaunchCooperativeKernel(const void* f, dim3 gridDim, dim3 blockDimX,
|
||||
void** kernelParams, unsigned int sharedMemBytes,
|
||||
@@ -2917,7 +2989,7 @@ hipError_t hipLaunchCooperativeKernel(const void* f, dim3 gridDim, dim3 blockDim
|
||||
* @param [in] numDevices Size of the launchParamsList array.
|
||||
* @param [in] flags Flags to control launch behavior.
|
||||
*
|
||||
* @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue
|
||||
* @returns hipSuccess, hipInvalidDevice, hipErrorNotInitialized, hipErrorInvalidValue, hipErrorCooperativeLaunchTooLarge
|
||||
*/
|
||||
hipError_t hipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsList,
|
||||
int numDevices, unsigned int flags);
|
||||
@@ -2954,15 +3026,37 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
* @brief Returns occupancy for a device function.
|
||||
*
|
||||
* @param [out] numBlocks Returned occupancy
|
||||
* @param [in] func Kernel function for which occupancy is calulated
|
||||
* @param [in] func Kernel function (hipFunction) for which occupancy is calulated
|
||||
* @param [in] blockSize Block size the kernel is intended to be launched with
|
||||
* @param [in] dynSharedMemPerBlk dynamic shared memory usage (in bytes) intended for each block
|
||||
*/
|
||||
hipError_t hipDrvOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk);
|
||||
|
||||
/**
|
||||
* @brief Returns occupancy for a device function.
|
||||
*
|
||||
* @param [out] numBlocks Returned occupancy
|
||||
* @param [in] f Kernel function for which occupancy is calulated
|
||||
* @param [in] blockSize Block size the kernel is intended to be launched with
|
||||
* @param [in] dynSharedMemPerBlk dynamic shared memory usage (in bytes) intended for each block
|
||||
* @param [in] flags Extra flags for occupancy calculation (currently ignored)
|
||||
*/
|
||||
hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
uint32_t* numBlocks, hipFunction_t f, uint32_t blockSize, size_t dynSharedMemPerBlk, unsigned int flags);
|
||||
uint32_t* numBlocks, hipFunction_t f, uint32_t blockSize, size_t dynSharedMemPerBlk, unsigned int flags __dparm(hipOccupancyDefault));
|
||||
|
||||
/**
|
||||
* @brief Returns occupancy for a device function.
|
||||
*
|
||||
* @param [out] numBlocks Returned occupancy
|
||||
* @param [in] f Kernel function(hipFunction_t) for which occupancy is calulated
|
||||
* @param [in] blockSize Block size the kernel is intended to be launched with
|
||||
* @param [in] dynSharedMemPerBlk dynamic shared memory usage (in bytes) intended for each block
|
||||
* @param [in] flags Extra flags for occupancy calculation (currently ignored)
|
||||
*/
|
||||
hipError_t hipDrvOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk, unsigned int flags);
|
||||
|
||||
#if __HIP_VDI__ && !defined(__HCC__)
|
||||
/**
|
||||
* @brief Launches kernels on multiple devices and guarantees all specified kernels are dispatched
|
||||
* on respective streams before enqueuing any other work on the specified streams from any other threads
|
||||
@@ -2977,7 +3071,6 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList,
|
||||
int numDevices, unsigned int flags);
|
||||
|
||||
#endif
|
||||
|
||||
// doxygen end Version Management
|
||||
/**
|
||||
@@ -3221,6 +3314,206 @@ hipError_t hipLaunchKernel(const void* function_address,
|
||||
size_t sharedMemBytes __dparm(0),
|
||||
hipStream_t stream __dparm(0));
|
||||
|
||||
#if __HIP_VDI__
|
||||
hipError_t hipBindTexture(
|
||||
size_t* offset,
|
||||
const textureReference* tex,
|
||||
const void* devPtr,
|
||||
const hipChannelFormatDesc* desc,
|
||||
size_t size = UINT_MAX);
|
||||
|
||||
hipError_t hipBindTexture2D(
|
||||
size_t* offset,
|
||||
const textureReference* tex,
|
||||
const void* devPtr,
|
||||
const hipChannelFormatDesc* desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch);
|
||||
|
||||
hipError_t hipBindTextureToArray(
|
||||
const textureReference* tex,
|
||||
hipArray_const_t array,
|
||||
const hipChannelFormatDesc* desc);
|
||||
|
||||
hipError_t hipBindTextureToMipmappedArray(
|
||||
const textureReference* tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc* desc);
|
||||
|
||||
hipError_t hipGetTextureAlignmentOffset(
|
||||
size_t* offset,
|
||||
const textureReference* texref);
|
||||
|
||||
hipError_t hipGetTextureReference(
|
||||
const textureReference** texref,
|
||||
const void* symbol);
|
||||
|
||||
hipError_t hipUnbindTexture(const textureReference* tex);
|
||||
|
||||
hipError_t hipCreateTextureObject(
|
||||
hipTextureObject_t* pTexObject,
|
||||
const hipResourceDesc* pResDesc,
|
||||
const hipTextureDesc* pTexDesc,
|
||||
const hipResourceViewDesc* pResViewDesc);
|
||||
|
||||
hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject);
|
||||
|
||||
hipError_t hipGetChannelDesc(
|
||||
hipChannelFormatDesc* desc,
|
||||
hipArray_const_t array);
|
||||
|
||||
hipError_t hipGetTextureObjectResourceDesc(
|
||||
hipResourceDesc* pResDesc,
|
||||
hipTextureObject_t textureObject);
|
||||
|
||||
hipError_t hipGetTextureObjectResourceViewDesc(
|
||||
hipResourceViewDesc* pResViewDesc,
|
||||
hipTextureObject_t textureObject);
|
||||
|
||||
hipError_t hipGetTextureObjectTextureDesc(
|
||||
hipTextureDesc* pTexDesc,
|
||||
hipTextureObject_t textureObject);
|
||||
|
||||
hipError_t hipTexRefGetAddress(
|
||||
hipDeviceptr_t* dev_ptr,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetAddressMode(
|
||||
hipTextureAddressMode* pam,
|
||||
const textureReference* texRef,
|
||||
int dim);
|
||||
|
||||
hipError_t hipTexRefGetFilterMode(
|
||||
hipTextureFilterMode* pfm,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetFlags(
|
||||
unsigned int* pFlags,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetFormat(
|
||||
hipArray_Format* pFormat,
|
||||
int* pNumChannels,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetMaxAnisotropy(
|
||||
int* pmaxAnsio,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetMipmapFilterMode(
|
||||
hipTextureFilterMode* pfm,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetMipmapLevelBias(
|
||||
float* pbias,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetMipmapLevelClamp(
|
||||
float* pminMipmapLevelClamp,
|
||||
float* pmaxMipmapLevelClamp,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefGetMipMappedArray(
|
||||
hipMipmappedArray_t* pArray,
|
||||
const textureReference* texRef);
|
||||
|
||||
hipError_t hipTexRefSetAddress(
|
||||
size_t* ByteOffset,
|
||||
textureReference* texRef,
|
||||
hipDeviceptr_t dptr,
|
||||
size_t bytes);
|
||||
|
||||
hipError_t hipTexRefSetAddress2D(
|
||||
textureReference* texRef,
|
||||
const HIP_ARRAY_DESCRIPTOR* desc,
|
||||
hipDeviceptr_t dptr,
|
||||
size_t Pitch);
|
||||
|
||||
hipError_t hipTexRefSetAddressMode(
|
||||
textureReference* texRef,
|
||||
int dim,
|
||||
hipTextureAddressMode am);
|
||||
|
||||
hipError_t hipTexRefSetArray(
|
||||
textureReference* tex,
|
||||
hipArray_const_t array,
|
||||
unsigned int flags);
|
||||
|
||||
hipError_t hipTexRefSetBorderColor(
|
||||
textureReference* texRef,
|
||||
float* pBorderColor);
|
||||
|
||||
hipError_t hipTexRefSetFilterMode(
|
||||
textureReference* texRef,
|
||||
hipTextureFilterMode fm);
|
||||
|
||||
hipError_t hipTexRefSetFlags(
|
||||
textureReference* texRef,
|
||||
unsigned int Flags);
|
||||
|
||||
hipError_t hipTexRefSetFormat(
|
||||
textureReference* texRef,
|
||||
hipArray_Format fmt,
|
||||
int NumPackedComponents);
|
||||
|
||||
hipError_t hipTexRefSetMaxAnisotropy(
|
||||
textureReference* texRef,
|
||||
unsigned int maxAniso);
|
||||
|
||||
hipError_t hipTexRefSetMipmapFilterMode(
|
||||
textureReference* texRef,
|
||||
hipTextureFilterMode fm);
|
||||
|
||||
hipError_t hipTexRefSetMipmapLevelBias(
|
||||
textureReference* texRef,
|
||||
float bias);
|
||||
|
||||
hipError_t hipTexRefSetMipmapLevelClamp(
|
||||
textureReference* texRef,
|
||||
float minMipMapLevelClamp,
|
||||
float maxMipMapLevelClamp);
|
||||
|
||||
hipError_t hipTexRefSetMipmappedArray(
|
||||
textureReference* texRef,
|
||||
hipMipmappedArray* mipmappedArray,
|
||||
unsigned int Flags);
|
||||
|
||||
hipError_t hipMipmappedArrayCreate(
|
||||
hipMipmappedArray_t* pHandle,
|
||||
HIP_ARRAY3D_DESCRIPTOR* pMipmappedArrayDesc,
|
||||
unsigned int numMipmapLevels);
|
||||
|
||||
hipError_t hipMipmappedArrayDestroy(
|
||||
hipMipmappedArray_t hMipmappedArray);
|
||||
|
||||
hipError_t hipMipmappedArrayGetLevel(
|
||||
hipArray_t* pLevelArray,
|
||||
hipMipmappedArray_t hMipMappedArray,
|
||||
unsigned int level);
|
||||
|
||||
hipError_t hipTexObjectCreate(
|
||||
hipTextureObject_t* pTexObject,
|
||||
const HIP_RESOURCE_DESC* pResDesc,
|
||||
const HIP_TEXTURE_DESC* pTexDesc,
|
||||
const HIP_RESOURCE_VIEW_DESC* pResViewDesc);
|
||||
|
||||
hipError_t hipTexObjectDestroy(
|
||||
hipTextureObject_t texObject);
|
||||
|
||||
hipError_t hipTexObjectGetResourceDesc(
|
||||
HIP_RESOURCE_DESC* pResDesc,
|
||||
hipTextureObject_t texObject);
|
||||
|
||||
hipError_t hipTexObjectGetResourceViewDesc(
|
||||
HIP_RESOURCE_VIEW_DESC* pResViewDesc,
|
||||
hipTextureObject_t texObject);
|
||||
|
||||
hipError_t hipTexObjectGetTextureDesc(
|
||||
HIP_TEXTURE_DESC* pTexDesc,
|
||||
hipTextureObject_t texObject);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -3245,6 +3538,46 @@ static hipError_t __host__ inline hipOccupancyMaxActiveBlocksPerMultiprocessorWi
|
||||
}
|
||||
#endif // defined(__cplusplus) && !defined(__HCC__) && defined(__clang__) && defined(__HIP__)
|
||||
|
||||
#if defined(__cplusplus) && !defined(__HCC__)
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipGetSymbolAddress(void** devPtr, const T &symbol) {
|
||||
return ::hipGetSymbolAddress(devPtr, (const void *)&symbol);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipGetSymbolSize(size_t* size, const T &symbol) {
|
||||
return ::hipGetSymbolSize(size, (const void *)&symbol);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipMemcpyToSymbol(const T& symbol, const void* src, size_t sizeBytes,
|
||||
size_t offset __dparm(0),
|
||||
hipMemcpyKind kind __dparm(hipMemcpyHostToDevice)) {
|
||||
return ::hipMemcpyToSymbol((const void*)&symbol, src, sizeBytes, offset, kind);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipMemcpyToSymbolAsync(const T& symbol, const void* src, size_t sizeBytes, size_t offset,
|
||||
hipMemcpyKind kind, hipStream_t stream __dparm(0)) {
|
||||
return ::hipMemcpyToSymbolAsync((const void*)&symbol, src, sizeBytes, offset, kind, stream);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipMemcpyFromSymbol(void* dst, const T &symbol,
|
||||
size_t sizeBytes, size_t offset __dparm(0),
|
||||
hipMemcpyKind kind __dparm(hipMemcpyDeviceToHost)) {
|
||||
return ::hipMemcpyFromSymbol(dst, (const void*)&symbol, sizeBytes, offset, kind);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
hipError_t hipMemcpyFromSymbolAsync(void* dst, const T& symbol, size_t sizeBytes, size_t offset,
|
||||
hipMemcpyKind kind, hipStream_t stream __dparm(0)) {
|
||||
return ::hipMemcpyFromSymbolAsync(dst, (const void*)&symbol, sizeBytes, offset, kind, stream);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if USE_PROF_API
|
||||
#include <hip/hcc_detail/hip_prof_str.h>
|
||||
#endif
|
||||
@@ -3269,12 +3602,16 @@ const char* hipKernelNameRef(const hipFunction_t f);
|
||||
|
||||
class TlsData;
|
||||
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr,
|
||||
const hipChannelFormatDesc* desc, size_t size = UINT_MAX);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
hipError_t ihipBindTextureImpl(TlsData *tls, int dim, enum hipTextureReadMode readMode, size_t* offset,
|
||||
const void* devPtr, const struct hipChannelFormatDesc* desc,
|
||||
size_t size, textureReference* tex);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture
|
||||
@@ -3291,11 +3628,13 @@ hipError_t ihipBindTextureImpl(TlsData *tls, int dim, enum hipTextureReadMode re
|
||||
* @param[in] size - Size of the memory area pointed to by devPtr
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
|
||||
**/
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture(size_t* offset, struct texture<T, dim, readMode>& tex, const void* devPtr,
|
||||
const struct hipChannelFormatDesc& desc, size_t size = UINT_MAX) {
|
||||
return ihipBindTextureImpl(nullptr, dim, readMode, offset, devPtr, &desc, size, &tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture
|
||||
@@ -3311,81 +3650,114 @@ hipError_t hipBindTexture(size_t* offset, struct texture<T, dim, readMode>& tex,
|
||||
* @param[in] size - Size of the memory area pointed to by devPtr
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
|
||||
**/
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture(size_t* offset, struct texture<T, dim, readMode>& tex, const void* devPtr,
|
||||
size_t size = UINT_MAX) {
|
||||
return ihipBindTextureImpl(nullptr, dim, readMode, offset, devPtr, &(tex.channelDesc), size, &tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
// C API
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* devPtr,
|
||||
const hipChannelFormatDesc* desc, size_t width, size_t height,
|
||||
size_t pitch);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
hipError_t ihipBindTexture2DImpl(int dim, enum hipTextureReadMode readMode, size_t* offset,
|
||||
const void* devPtr, const struct hipChannelFormatDesc* desc,
|
||||
size_t width, size_t height, textureReference* tex, size_t pitch);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture2D(size_t* offset, struct texture<T, dim, readMode>& tex,
|
||||
const void* devPtr, size_t width, size_t height, size_t pitch) {
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, &(tex.channelDesc), width, height,
|
||||
&tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture2D(size_t* offset, struct texture<T, dim, readMode>& tex,
|
||||
const void* devPtr, const struct hipChannelFormatDesc& desc,
|
||||
size_t width, size_t height, size_t pitch) {
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, &desc, width, height, &tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
// C API
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array,
|
||||
const hipChannelFormatDesc* desc);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
hipError_t ihipBindTextureToArrayImpl(TlsData *tls, int dim, enum hipTextureReadMode readMode,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
textureReference* tex);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex, hipArray_const_t array) {
|
||||
return ihipBindTextureToArrayImpl(nullptr, dim, readMode, array, tex.channelDesc, &tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex, hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc) {
|
||||
return ihipBindTextureToArrayImpl(nullptr, dim, readMode, array, desc, &tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
inline static hipError_t hipBindTextureToArray(struct texture<T, dim, readMode> *tex,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc* desc) {
|
||||
return ihipBindTextureToArrayImpl(nullptr, dim, readMode, array, *desc, tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
// C API
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipBindTextureToMipmappedArray(const textureReference* tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc* desc);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
|
||||
hipMipmappedArray_const_t mipmappedArray) {
|
||||
return hipSuccess;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc& desc) {
|
||||
return hipSuccess;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __HIP_VDI__ && !defined(__HCC__)
|
||||
|
||||
template <typename F>
|
||||
inline hipError_t hipOccupancyMaxPotentialBlockSize(uint32_t* gridSize, uint32_t* blockSize,
|
||||
F kernel, size_t dynSharedMemPerBlk, uint32_t blockSizeLimit) {
|
||||
return hipOccupancyMaxPotentialBlockSize(gridSize, blockSize,(hipFunction_t)kernel, dynSharedMemPerBlk, blockSizeLimit);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline hipError_t hipLaunchCooperativeKernel(T f, dim3 gridDim, dim3 blockDim,
|
||||
void** kernelParams, unsigned int sharedMemBytes, hipStream_t stream) {
|
||||
@@ -3415,15 +3787,22 @@ inline hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchPara
|
||||
*
|
||||
* @return #hipSuccess
|
||||
**/
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipUnbindTexture(const textureReference* tex);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
extern hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject);
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipUnbindTexture(struct texture<T, dim, readMode>& tex) {
|
||||
return ihipUnbindTextureImpl(tex.textureObject);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !__HIP_VDI__
|
||||
hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array);
|
||||
hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* texref);
|
||||
hipError_t hipGetTextureReference(const textureReference** texref, const void* symbol);
|
||||
@@ -3461,11 +3840,110 @@ hipError_t hipTexRefGetAddress(hipDeviceptr_t* dev_ptr, textureReference tex);
|
||||
|
||||
hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc,
|
||||
hipDeviceptr_t devPtr, size_t pitch);
|
||||
#endif
|
||||
|
||||
hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc);
|
||||
|
||||
hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject);
|
||||
|
||||
#if __HIP_VDI__
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTexture(
|
||||
size_t *offset,
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
return hipBindTexture(offset, tex, devPtr, tex.channelDesc, size);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTexture(
|
||||
size_t *offset,
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc &desc,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
return hipBindTexture(offset, &tex, devPtr, &desc, size);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTexture2D(
|
||||
size_t *offset,
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return hipBindTexture2D(offset, &tex, devPtr, &tex.channelDesc, width, height, pitch);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTexture2D(
|
||||
size_t *offset,
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc &desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return hipBindTexture2D(offset, &tex, devPtr, &desc, width, height, pitch);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTextureToArray(
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
hipArray_const_t array)
|
||||
{
|
||||
struct cudaChannelFormatDesc desc;
|
||||
hipError_t err = hipGetChannelDesc(&desc, array);
|
||||
return (err == hipSuccess) ? hipBindTextureToArray(tex, array, desc) : err;
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTextureToArray(
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc &desc)
|
||||
{
|
||||
return hipBindTextureToArray(&tex, array, &desc);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTextureToMipmappedArray(
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
hipMipmappedArray_const_t mipmappedArray)
|
||||
{
|
||||
struct hipChannelFormatDesc desc;
|
||||
hipArray_t levelArray;
|
||||
hipError_t err = hipGetMipmappedArrayLevel(&levelArray, mipmappedArray, 0);
|
||||
if (err != hipSuccess) {
|
||||
return err;
|
||||
}
|
||||
err = hipGetChannelDesc(&desc, levelArray);
|
||||
return (err == hipSuccess) ? hipBindTextureToMipmappedArray(tex, mipmappedArray, desc) : err;
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipBindTextureToMipmappedArray(
|
||||
const struct texture<T, dim, readMode> &tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const struct cudaChannelFormatDesc &desc)
|
||||
{
|
||||
return hipBindTextureToMipmappedArray(&tex, mipmappedArray, &desc);
|
||||
}
|
||||
|
||||
template<class T, int dim, enum hipTextureReadMode readMode>
|
||||
static inline hipError_t hipUnbindTexture(
|
||||
const struct texture<T, dim, readMode> &tex)
|
||||
{
|
||||
return hipUnbindTexture(&tex);
|
||||
}
|
||||
#endif
|
||||
|
||||
// doxygen end Texture
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -57,25 +57,27 @@ struct __HIP_TEXTURE_ATTRIB texture : public textureReference {
|
||||
texture(int norm = 0, enum hipTextureFilterMode fMode = hipFilterModePoint,
|
||||
enum hipTextureAddressMode aMode = hipAddressModeClamp) {
|
||||
normalized = norm;
|
||||
readMode = hipReadModeNormalizedFloat;
|
||||
readMode = mode;
|
||||
filterMode = fMode;
|
||||
addressMode[0] = aMode;
|
||||
addressMode[1] = aMode;
|
||||
addressMode[2] = aMode;
|
||||
channelDesc = hipCreateChannelDesc<T>();
|
||||
sRGB = 0;
|
||||
textureObject = nullptr;
|
||||
}
|
||||
|
||||
texture(int norm, enum hipTextureFilterMode fMode, enum hipTextureAddressMode aMode,
|
||||
struct hipChannelFormatDesc desc) {
|
||||
normalized = norm;
|
||||
readMode = hipReadModeNormalizedFloat;
|
||||
readMode = mode;
|
||||
filterMode = fMode;
|
||||
addressMode[0] = aMode;
|
||||
addressMode[1] = aMode;
|
||||
addressMode[2] = aMode;
|
||||
channelDesc = desc;
|
||||
sRGB = 0;
|
||||
textureObject = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,10 +19,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef HIPRTC_H
|
||||
#define HIPRTC_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
enum hiprtcResult {
|
||||
HIPRTC_SUCCESS = 0,
|
||||
@@ -41,29 +45,22 @@ enum hiprtcResult {
|
||||
|
||||
const char* hiprtcGetErrorString(hiprtcResult result);
|
||||
|
||||
inline
|
||||
hiprtcResult hiprtcVersion(int* major, int* minor) noexcept
|
||||
{ // TODO: NVRTC versioning is somewhat unclear.
|
||||
if (!major || !minor) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
|
||||
// TODO: this should be generic / set by the build infrastructure.
|
||||
*major = 9;
|
||||
*minor = 0;
|
||||
hiprtcResult hiprtcVersion(int* major, int* minor);
|
||||
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
struct _hiprtcProgram;
|
||||
using hiprtcProgram = _hiprtcProgram*;
|
||||
typedef struct _hiprtcProgram* hiprtcProgram;
|
||||
|
||||
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog,
|
||||
const char* name_expression);
|
||||
|
||||
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions,
|
||||
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog,
|
||||
int numOptions,
|
||||
const char** options);
|
||||
|
||||
hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog, const char* src,
|
||||
const char* name, int numHeaders,
|
||||
hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog,
|
||||
const char* src,
|
||||
const char* name,
|
||||
int numHeaders,
|
||||
const char** headers,
|
||||
const char** includeNames);
|
||||
|
||||
@@ -76,37 +73,14 @@ hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog,
|
||||
hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char* log);
|
||||
|
||||
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog,
|
||||
std::size_t* logSizeRet);
|
||||
size_t* logSizeRet);
|
||||
|
||||
hiprtcResult hiprtcGetCode(hiprtcProgram prog, char* code);
|
||||
|
||||
hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, std::size_t* codeSizeRet);
|
||||
hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t* codeSizeRet);
|
||||
|
||||
namespace hip_impl
|
||||
{
|
||||
char* demangle(const char* mangled_expression);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if defined(HIPRTC_GET_TYPE_NAME)
|
||||
#include <typeinfo>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <dbghelp.h>
|
||||
|
||||
template<typename>
|
||||
hiprtcResult hiprtcGetTypeName(std::string*) = delete;
|
||||
#else
|
||||
template<typename T>
|
||||
inline
|
||||
hiprtcResult hiprtcGetTypeName(std::string* result)
|
||||
{
|
||||
if (!result) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
|
||||
char * res= hip_impl::demangle(typeid(T).name());
|
||||
result->assign(res == nullptr ? "" : res);
|
||||
std::free(res);
|
||||
return (result->empty()) ? HIPRTC_ERROR_INTERNAL_ERROR :
|
||||
HIPRTC_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif //HIPRTC_H
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hip/hip_vector_types.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#define ADDRESS_SPACE_CONSTANT __attribute__((address_space(4)))
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_1Db(unsigned int ADDRESS_SPACE_CONSTANT*i, int c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int f, int l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_load_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int f, int l);
|
||||
|
||||
__device__ void __ockl_image_store_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, int c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, int2::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ void __ockl_image_store_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, int4::Native_vec_ c, int l, float4::Native_vec_ p);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_grad_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c, float dx, float dy);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_grad_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float dx, float dy);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_grad_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float2::Native_vec_ dx, float2::Native_vec_ dy);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_grad_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float2::Native_vec_ dx, float2::Native_vec_ dy);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_grad_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float4::Native_vec_ dx, float4::Native_vec_ dy);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_1D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_1Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_2Da(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_3D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_CM(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_sample_lod_CMa(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float4::Native_vec_ c, float l);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_gather4r_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_gather4g_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_gather4b_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
__device__ float4::Native_vec_ __ockl_image_gather4a_2D(unsigned int ADDRESS_SPACE_CONSTANT*i, unsigned int ADDRESS_SPACE_CONSTANT*s, float2::Native_vec_ c);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,386 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#include <hip/hip_vector_types.h>
|
||||
#include <hip/texture_types.h>
|
||||
#include <hip/hcc_detail/ockl_image.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#define TEXTURE_PARAMETERS_INIT \
|
||||
unsigned int ADDRESS_SPACE_CONSTANT* i = (unsigned int ADDRESS_SPACE_CONSTANT*)t.textureObject; \
|
||||
unsigned int ADDRESS_SPACE_CONSTANT* s = i + HIP_SAMPLER_OBJECT_OFFSET_DWORD;
|
||||
|
||||
template<typename T>
|
||||
struct __hip_is_tex_channel_type
|
||||
{
|
||||
static constexpr bool value =
|
||||
std::is_same<T, char>::value ||
|
||||
std::is_same<T, unsigned char>::value ||
|
||||
std::is_same<T, short>::value ||
|
||||
std::is_same<T, unsigned short>::value ||
|
||||
std::is_same<T, int>::value ||
|
||||
std::is_same<T, unsigned int>::value ||
|
||||
std::is_same<T, float>::value;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_is_tex_channel_type<HIP_vector_type<T, rank>>
|
||||
{
|
||||
static constexpr bool value =
|
||||
__hip_is_tex_channel_type<T>::value &&
|
||||
((rank == 1) ||
|
||||
(rank == 2) ||
|
||||
(rank == 4));
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct __hip_is_tex_normalized_channel_type
|
||||
{
|
||||
static constexpr bool value =
|
||||
std::is_same<T, char>::value ||
|
||||
std::is_same<T, unsigned char>::value ||
|
||||
std::is_same<T, short>::value ||
|
||||
std::is_same<T, unsigned short>::value;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_is_tex_normalized_channel_type<HIP_vector_type<T, rank>>
|
||||
{
|
||||
static constexpr bool value =
|
||||
__hip_is_tex_normalized_channel_type<T>::value &&
|
||||
((rank == 1) ||
|
||||
(rank == 2) ||
|
||||
(rank == 4));
|
||||
};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
hipTextureReadMode readMode,
|
||||
typename Enable = void>
|
||||
struct __hip_tex_ret
|
||||
{
|
||||
static_assert(std::is_same<Enable, void>::value, "Invalid channel type!");
|
||||
};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
hipTextureReadMode readMode>
|
||||
using __hip_tex_ret_t = typename __hip_tex_ret<T, readMode, bool>::type;
|
||||
|
||||
template <typename T>
|
||||
struct __hip_tex_ret<
|
||||
T,
|
||||
hipReadModeElementType,
|
||||
typename std::enable_if<__hip_is_tex_channel_type<T>::value, bool>::type>
|
||||
{
|
||||
using type = T;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_tex_ret<
|
||||
HIP_vector_type<T, rank>,
|
||||
hipReadModeElementType,
|
||||
typename std::enable_if<__hip_is_tex_channel_type<HIP_vector_type<T, rank>>::value, bool>::type>
|
||||
{
|
||||
using type = HIP_vector_type<__hip_tex_ret_t<T, hipReadModeElementType>, rank>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct __hip_tex_ret<
|
||||
T,
|
||||
hipReadModeNormalizedFloat,
|
||||
typename std::enable_if<__hip_is_tex_normalized_channel_type<T>::value, bool>::type>
|
||||
{
|
||||
using type = float;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_tex_ret<
|
||||
HIP_vector_type<T, rank>,
|
||||
hipReadModeNormalizedFloat,
|
||||
typename std::enable_if<__hip_is_tex_normalized_channel_type<HIP_vector_type<T, rank>>::value, bool>::type>
|
||||
{
|
||||
using type = HIP_vector_type<__hip_tex_ret_t<T, hipReadModeNormalizedFloat>, rank>;
|
||||
};
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1Dfetch(texture<T, hipTextureType1D, readMode> t, int x)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_load_1Db(i, x);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1D(texture<T, hipTextureType1D, readMode> t, float x)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_1D(i, s, x);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2D(texture<T, hipTextureType2D, readMode> t, float x, float y)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1DLayered(texture<T, hipTextureType1DLayered, readMode> t, float x, int layer)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_1Da(i, s, float2(x, layer).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2DLayered(texture<T, hipTextureType2DLayered, readMode> t, float x, float y, int layer)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_2Da(i, s, float4(x, y, layer, 0.0f).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex3D(texture<T, hipTextureType3D, readMode> t, float x, float y, float z)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_3D(i, s, float4(x, y, z, 0.0f).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemap(texture<T, hipTextureTypeCubemap, readMode> t, float x, float y, float z)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_CM(i, s, float4(x, y, z, 0.0f).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1DLod(texture<T, hipTextureType1D, readMode> t, float x, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_1D(i, s, x, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2DLod(texture<T, hipTextureType2D, readMode> t, float x, float y, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_2D(i, s, float2(x, y).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1DLayeredLod(texture<T, hipTextureType1DLayered, readMode> t, float x, int layer, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_1Da(i, s, float2(x, layer).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2DLayeredLod(texture<T, hipTextureType2DLayered, readMode> t, float x, float y, int layer, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_2Da(i, s, float4(x, y, layer, 0.0f).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex3DLod(texture<T, hipTextureType3D, readMode> t, float x, float y, float z, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_3D(i, s, float4(x, y, z, 0.0f).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemapLod(texture<T, hipTextureTypeCubemap, readMode> t, float x, float y, float z, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_CM(i, s, float4(x, y, z, 0.0f).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemapLayered(texture<T, hipTextureTypeCubemapLayered, readMode> t, float x, float y, float z, int layer)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_CMa(i, s, float4(x, y, z, layer).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemapLayeredLod(texture<T, hipTextureTypeCubemapLayered, readMode> t, float x, float y, float z, int layer, float level)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_lod_CMa(i, s, float4(x, y, z, layer).data, level);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemapGrad(texture<T, hipTextureTypeCubemap, readMode> t, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
// TODO missing in device libs.
|
||||
// auto tmp = __ockl_image_sample_grad_CM(i, s, float4(x, y, z, 0.0f).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
// return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> texCubemapLayeredGrad(texture<T, hipTextureTypeCubemapLayered, readMode> t, float x, float y, float z, int layer, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
// TODO missing in device libs.
|
||||
// auto tmp = __ockl_image_sample_grad_CMa(i, s, float4(x, y, z, layer).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
// return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1DGrad(texture<T, hipTextureType1D, readMode> t, float x, float dPdx, float dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_grad_1D(i, s, x, dPdx, dPdy);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2DGrad(texture<T, hipTextureType2D, readMode> t, float x, float y, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_grad_2D(i, s, float2(x, y).data, float2(dPdx.x, dPdx.y).data, float2(dPdy.x, dPdy.y).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex1DLayeredGrad(texture<T, hipTextureType1DLayered, readMode> t, float x, int layer, float dPdx, float dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_grad_1Da(i, s, float2(x, layer).data, dPdx, dPdy);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex2DLayeredGrad(texture<T, hipTextureType2DLayered, readMode> t, float x, float y, int layer, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_grad_2Da(i, s, float4(x, y, layer, 0.0f).data, float2(dPdx.x, dPdx.y).data, float2(dPdy.x, dPdy.y).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex_ret_t<T, readMode> tex3DGrad(texture<T, hipTextureType3D, readMode> t, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
auto tmp = __ockl_image_sample_grad_3D(i, s, float4(x, y, z, 0.0f).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
return *reinterpret_cast<__hip_tex_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
hipTextureReadMode readMode,
|
||||
typename Enable = void>
|
||||
struct __hip_tex2dgather_ret
|
||||
{
|
||||
static_assert(std::is_same<Enable, void>::value, "Invalid channel type!");
|
||||
};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
hipTextureReadMode readMode>
|
||||
using __hip_tex2dgather_ret_t = typename __hip_tex2dgather_ret<T, readMode, bool>::type;
|
||||
|
||||
template <typename T>
|
||||
struct __hip_tex2dgather_ret<
|
||||
T,
|
||||
hipReadModeElementType,
|
||||
typename std::enable_if<__hip_is_tex_channel_type<T>::value, bool>::type>
|
||||
{
|
||||
using type = HIP_vector_type<T, 4>;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_tex2dgather_ret<
|
||||
HIP_vector_type<T, rank>,
|
||||
hipReadModeElementType,
|
||||
typename std::enable_if<__hip_is_tex_channel_type<HIP_vector_type<T, rank>>::value, bool>::type>
|
||||
{
|
||||
using type = HIP_vector_type<T, 4>;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct __hip_tex2dgather_ret<
|
||||
T,
|
||||
hipReadModeNormalizedFloat,
|
||||
typename std::enable_if<__hip_is_tex_normalized_channel_type<T>::value, bool>::type>
|
||||
{
|
||||
using type = float4;
|
||||
};
|
||||
|
||||
template <typename T, hipTextureReadMode readMode>
|
||||
static __forceinline__ __device__ __hip_tex2dgather_ret_t<T, readMode> tex2Dgather(texture<T, hipTextureType2D, readMode> t, float x, float y, int comp=0)
|
||||
{
|
||||
TEXTURE_PARAMETERS_INIT;
|
||||
switch (comp) {
|
||||
case 1: {
|
||||
auto tmp = __ockl_image_gather4g_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<__hip_tex2dgather_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
case 2: {
|
||||
auto tmp = __ockl_image_gather4b_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<__hip_tex2dgather_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
case 3: {
|
||||
auto tmp = __ockl_image_gather4a_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<__hip_tex2dgather_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
default: {
|
||||
auto tmp = __ockl_image_gather4r_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<__hip_tex2dgather_ret_t<T, readMode>*>(&tmp);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,501 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#include <hip/hip_vector_types.h>
|
||||
#include <hip/hip_texture_types.h>
|
||||
#include <hip/hcc_detail/ockl_image.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#define TEXTURE_OBJECT_PARAMETERS_INIT \
|
||||
unsigned int ADDRESS_SPACE_CONSTANT* i = (unsigned int ADDRESS_SPACE_CONSTANT*)textureObject; \
|
||||
unsigned int ADDRESS_SPACE_CONSTANT* s = i + HIP_SAMPLER_OBJECT_OFFSET_DWORD;
|
||||
|
||||
template<typename T>
|
||||
struct __hip_is_itex_channel_type
|
||||
{
|
||||
static constexpr bool value =
|
||||
std::is_same<T, char>::value ||
|
||||
std::is_same<T, unsigned char>::value ||
|
||||
std::is_same<T, short>::value ||
|
||||
std::is_same<T, unsigned short>::value ||
|
||||
std::is_same<T, int>::value ||
|
||||
std::is_same<T, unsigned int>::value ||
|
||||
std::is_same<T, float>::value;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
unsigned int rank>
|
||||
struct __hip_is_itex_channel_type<HIP_vector_type<T, rank>>
|
||||
{
|
||||
static constexpr bool value =
|
||||
__hip_is_itex_channel_type<T>::value &&
|
||||
((rank == 1) ||
|
||||
(rank == 2) ||
|
||||
(rank == 4));
|
||||
};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1Dfetch(hipTextureObject_t textureObject, int x)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_load_1Db(i, x);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1Dfetch(T *ptr, hipTextureObject_t textureObject, int x)
|
||||
{
|
||||
*ptr = tex1Dfetch<T>(textureObject, x);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1D(hipTextureObject_t textureObject, float x)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_1D(i, s, x);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1D(T *ptr, hipTextureObject_t textureObject, float x)
|
||||
{
|
||||
*ptr = tex1D<T>(textureObject, x);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2D(hipTextureObject_t textureObject, float x, float y)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2D(T *ptr, hipTextureObject_t textureObject, float x, float y)
|
||||
{
|
||||
*ptr = tex2D<T>(textureObject, x, y);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex3D(hipTextureObject_t textureObject, float x, float y, float z)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_3D(i, s, float4(x, y, z, 0.0f).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex3D(T *ptr, hipTextureObject_t textureObject, float x, float y, float z)
|
||||
{
|
||||
*ptr = tex3D<T>(textureObject, x, y, z);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1DLayered(hipTextureObject_t textureObject, float x, int layer)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_1Da(i, s, float2(x, layer).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1DLayered(T *ptr, hipTextureObject_t textureObject, float x, int layer)
|
||||
{
|
||||
*ptr = tex1DLayered<T>(textureObject, x, layer);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2DLayered(hipTextureObject_t textureObject, float x, float y, int layer)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_2Da(i, s, float4(x, y, layer, 0.0f).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2DLayered(T *ptr, hipTextureObject_t textureObject, float x, float y, int layer)
|
||||
{
|
||||
*ptr = tex1DLayered<T>(textureObject, x, y, layer);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemap(hipTextureObject_t textureObject, float x, float y, float z)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_CM(i, s, float4(x, y, z, 0.0f).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemap(T *ptr, hipTextureObject_t textureObject, float x, float y, float z)
|
||||
{
|
||||
*ptr = texCubemap<T>(textureObject, x, y, z);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemapLayered(hipTextureObject_t textureObject, float x, float y, float z, int layer)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_CMa(i, s, float4(x, y, z, layer).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemapLayered(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, int layer)
|
||||
{
|
||||
*ptr = texCubemapLayered<T>(textureObject, x, y, z, layer);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2Dgather(hipTextureObject_t textureObject, float x, float y, int comp = 0)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
switch (comp) {
|
||||
case 1: {
|
||||
auto tmp = __ockl_image_gather4r_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
auto tmp = __ockl_image_gather4g_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
auto tmp = __ockl_image_gather4b_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
auto tmp = __ockl_image_gather4a_2D(i, s, float2(x, y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
break;
|
||||
}
|
||||
};
|
||||
return {};
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2Dgather(T *ptr, hipTextureObject_t textureObject, float x, float y, int comp = 0)
|
||||
{
|
||||
*ptr = texCubemapLayered<T>(textureObject, x, y, comp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1DLod(hipTextureObject_t textureObject, float x, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_lod_1D(i, s, x, level);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1DLod(T *ptr, hipTextureObject_t textureObject, float x, float level)
|
||||
{
|
||||
*ptr = tex1DLod<T>(textureObject, x, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2DLod(hipTextureObject_t textureObject, float x, float y, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_lod_2D(i, s, float2(x, y).data, level);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2DLod(T *ptr, hipTextureObject_t textureObject, float x, float y, float level)
|
||||
{
|
||||
*ptr = tex2DLod<T>(textureObject, x, y, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex3DLod(hipTextureObject_t textureObject, float x, float y, float z, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_lod_3D(i, s, float4(x, y, z, 0.0f).data, level);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex3DLod(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, float level)
|
||||
{
|
||||
*ptr = tex3DLod<T>(textureObject, x, y, z, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1DLayeredLod(hipTextureObject_t textureObject, float x, int layer, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_1Da(i, s, float2(x, layer).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1DLayeredLod(T *ptr, hipTextureObject_t textureObject, float x, int layer, float level)
|
||||
{
|
||||
*ptr = tex1DLayeredLod<T>(textureObject, x, layer, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2DLayeredLod(hipTextureObject_t textureObject, float x, float y, int layer, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_2Da(i, s, float4(x, y, layer, 0.0f).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2DLayeredLod(T *ptr, hipTextureObject_t textureObject, float x, float y, int layer, float level)
|
||||
{
|
||||
*ptr = tex2DLayeredLod<T>(textureObject, x, y, layer, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemapLod(hipTextureObject_t textureObject, float x, float y, float z, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_lod_CM(i, s, float4(x, y, z, 0.0f).data, level);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemapLod(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, float level)
|
||||
{
|
||||
*ptr = texCubemapLod<T>(textureObject, x, y, z, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemapGrad(hipTextureObject_t textureObject, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
// TODO missing in device libs.
|
||||
// auto tmp = __ockl_image_sample_grad_CM(i, s, float4(x, y, z, 0.0f).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
// return *reinterpret_cast<T*>(&tmp);
|
||||
return {};
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemapGrad(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
*ptr = texCubemapGrad<T>(textureObject, x, y, z, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemapLayeredLod(hipTextureObject_t textureObject, float x, float y, float z, int layer, float level)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_lod_CMa(i, s, float4(x, y, z, layer).data, level);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemapLayeredLod(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, int layer, float level)
|
||||
{
|
||||
*ptr = texCubemapLayeredLod<T>(textureObject, x, y, z, layer, level);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1DGrad(hipTextureObject_t textureObject, float x, float dPdx, float dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_grad_1D(i, s, x, dPdx, dPdy);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1DGrad(T *ptr, hipTextureObject_t textureObject, float x, float dPdx, float dPdy)
|
||||
{
|
||||
*ptr = tex1DGrad<T>(textureObject, x, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2DGrad(hipTextureObject_t textureObject, float x, float y, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_grad_2D(i, s, float2(x, y).data, float2(dPdx.x, dPdx.y).data, float2(dPdy.x, dPdy.y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2DGrad(T *ptr, hipTextureObject_t textureObject, float x, float y, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
*ptr = tex2DGrad<T>(textureObject, x, y, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex3DGrad(hipTextureObject_t textureObject, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_grad_3D(i, s, float4(x, y, z, 0.0f).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex3DGrad(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
*ptr = tex3DGrad<T>(textureObject, x, y, z, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex1DLayeredGrad(hipTextureObject_t textureObject, float x, int layer, float dPdx, float dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_grad_1Da(i, s, float2(x, layer).data, dPdx, dPdy);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex1DLayeredGrad(T *ptr, hipTextureObject_t textureObject, float x, int layer, float dPdx, float dPdy)
|
||||
{
|
||||
*ptr = tex1DLayeredGrad<T>(textureObject, x, layer, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T tex2DLayeredGrad(hipTextureObject_t textureObject, float x, float y, int layer, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
auto tmp = __ockl_image_sample_grad_2Da(i, s, float4(x, y, layer, 0.0f).data, float2(dPdx.x, dPdx.y).data, float2(dPdy.x, dPdy.y).data);
|
||||
return *reinterpret_cast<T*>(&tmp);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void tex2DLayeredGrad(T *ptr, hipTextureObject_t textureObject, float x, float y, int layer, float2 dPdx, float2 dPdy)
|
||||
{
|
||||
*ptr = tex2DLayeredGrad<T>(textureObject, x, y, layer, dPdx, dPdy);
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ T texCubemapLayeredGrad(hipTextureObject_t textureObject, float x, float y, float z, int layer, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
TEXTURE_OBJECT_PARAMETERS_INIT
|
||||
// TODO missing in device libs.
|
||||
// auto tmp = __ockl_image_sample_grad_CMa(i, s, float4(x, y, z, layer).data, float4(dPdx.x, dPdx.y, dPdx.z, 0.0f).data, float4(dPdy.x, dPdy.y, dPdy.z, 0.0f).data);
|
||||
// return *reinterpret_cast<T*>(&tmp);
|
||||
return {};
|
||||
}
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename std::enable_if<__hip_is_itex_channel_type<T>::value>::type* = nullptr>
|
||||
static __device__ void texCubemapLayeredGrad(T *ptr, hipTextureObject_t textureObject, float x, float y, float z, int layer, float4 dPdx, float4 dPdy)
|
||||
{
|
||||
*ptr = texCubemapLayeredGrad<T>(textureObject, x, y, z, layer, dPdx, dPdy);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +1,13 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@@ -23,23 +20,8 @@ THE SOFTWARE.
|
||||
#ifndef HIP_INCLUDE_HIP_HIP_PROFILE_H
|
||||
#define HIP_INCLUDE_HIP_HIP_PROFILE_H
|
||||
|
||||
#warning "HIP Profiling through markers is deprecated, please check roctrace/rocTX support."
|
||||
|
||||
#if not defined(ENABLE_HIP_PROFILE)
|
||||
#define ENABLE_HIP_PROFILE 1
|
||||
#endif
|
||||
|
||||
#if defined(__HIP_PLATFORM_HCC__) and (ENABLE_HIP_PROFILE == 1)
|
||||
#warning "HIP Markers are deprecated and would be removed soon."
|
||||
#include <CXLActivityLogger.h>
|
||||
#define HIP_SCOPED_MARKER(markerName, group) \
|
||||
amdtScopedMarker __scopedMarker(markerName, group, nullptr);
|
||||
#define HIP_BEGIN_MARKER(markerName, group) amdtBeginMarker(markerName, group, nullptr);
|
||||
#define HIP_END_MARKER() amdtEndMarker();
|
||||
#else
|
||||
#define HIP_SCOPED_MARKER(markerName, group)
|
||||
#define HIP_BEGIN_MARKER(markerName, group)
|
||||
#define HIP_END_MARKER()
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -255,6 +255,10 @@ typedef enum __HIP_NODISCARD hipError_t {
|
||||
713, ///< Produced when trying to unlock a non-page-locked memory.
|
||||
hipErrorLaunchFailure =
|
||||
719, ///< An exception occurred on the device while executing a kernel.
|
||||
hipErrorCooperativeLaunchTooLarge =
|
||||
720, ///< This error indicates that the number of blocks launched per grid for a kernel
|
||||
///< that was launched via cooperative launch APIs exceeds the maximum number of
|
||||
///< allowed blocks for the current device
|
||||
hipErrorNotSupported = 801, ///< Produced when the hip API is not supported/implemented
|
||||
hipErrorUnknown = 999, //< Unknown error.
|
||||
// HSA Runtime Error Codes start here.
|
||||
|
||||
@@ -140,6 +140,14 @@ typedef enum cudaChannelFormatKind hipChannelFormatKind;
|
||||
#define hipLimitMallocHeapSize cudaLimitMallocHeapSize
|
||||
#define hipIpcMemLazyEnablePeerAccess cudaIpcMemLazyEnablePeerAccess
|
||||
|
||||
#define hipOccupancyDefault cudaOccupancyDefault
|
||||
|
||||
#define hipCooperativeLaunchMultiDeviceNoPreSync \
|
||||
cudaCooperativeLaunchMultiDeviceNoPreSync
|
||||
#define hipCooperativeLaunchMultiDeviceNoPostSync \
|
||||
cudaCooperativeLaunchMultiDeviceNoPostSync
|
||||
|
||||
|
||||
// enum CUjit_option redefines
|
||||
#define hipJitOptionMaxRegisters CU_JIT_MAX_REGISTERS
|
||||
#define hipJitOptionThreadsPerBlock CU_JIT_THREADS_PER_BLOCK
|
||||
@@ -267,6 +275,8 @@ inline static hipError_t hipCUDAErrorTohipError(cudaError_t cuError) {
|
||||
return hipErrorNotInitialized;
|
||||
case cudaErrorLaunchFailure:
|
||||
return hipErrorLaunchFailure;
|
||||
case cudaErrorCooperativeLaunchTooLarge:
|
||||
return hipErrorCooperativeLaunchTooLarge;
|
||||
case cudaErrorPriorLaunchFailure:
|
||||
return hipErrorPriorLaunchFailure;
|
||||
case cudaErrorLaunchOutOfResources:
|
||||
@@ -445,6 +455,8 @@ inline static hipError_t hipCUResultTohipError(CUresult cuError) {
|
||||
return hipErrorHostMemoryNotRegistered;
|
||||
case CUDA_ERROR_LAUNCH_FAILED:
|
||||
return hipErrorLaunchFailure;
|
||||
case CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE:
|
||||
return hipErrorCooperativeLaunchTooLarge;
|
||||
case CUDA_ERROR_NOT_SUPPORTED:
|
||||
return hipErrorNotSupported;
|
||||
case CUDA_ERROR_UNKNOWN:
|
||||
@@ -601,6 +613,8 @@ inline static cudaError_t hipErrorToCudaError(hipError_t hError) {
|
||||
return cudaErrorSetOnActiveProcess;
|
||||
case hipErrorLaunchFailure:
|
||||
return cudaErrorLaunchFailure;
|
||||
case hipErrorCooperativeLaunchTooLarge:
|
||||
return cudaErrorCooperativeLaunchTooLarge;
|
||||
case hipErrorNotSupported:
|
||||
return cudaErrorNotSupported;
|
||||
// HSA: does not exist in CUDA
|
||||
|
||||
@@ -26,7 +26,7 @@ target_include_directories(ca PUBLIC ${PROJECT_SOURCE_DIR}/src)
|
||||
find_library(
|
||||
hsart NAMES libhsa-runtime64.so libhsa-runtime64.so.1 HINTS ${HSA_PATH}/lib)
|
||||
target_link_libraries(ca PUBLIC ${hsart})
|
||||
target_compile_options(ca PUBLIC -Wall)
|
||||
target_compile_options(ca PUBLIC -DDISABLE_REDUCED_GPU_BLOB_COPY -Wall)
|
||||
|
||||
install(TARGETS ca RUNTIME DESTINATION bin)
|
||||
#-------------------------------------CA---------------------------------------#
|
||||
#-------------------------------------CA---------------------------------------#
|
||||
|
||||
@@ -36,11 +36,7 @@ set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}
|
||||
set(CPACK_GENERATOR "TGZ;DEB;RPM")
|
||||
set(CPACK_BINARY_DEB "ON")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm")
|
||||
if(@COMPILE_HIP_ATP_MARKER@)
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), rocm-profiler, comgr (>= 1.1)")
|
||||
else()
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), comgr (>= 1.1)")
|
||||
endif()
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-base (= ${CPACK_PACKAGE_VERSION}), ${HCC_PACKAGE_NAME} (= @HCC_PACKAGE_VERSION@), comgr (>= 1.1)")
|
||||
set(CPACK_DEBIAN_PACKAGE_PROVIDES "hip_hcc")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES "hip_hcc")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "hip_hcc")
|
||||
@@ -50,11 +46,7 @@ set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst")
|
||||
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV " no")
|
||||
string(REPLACE "-" "_" HIP_BASE_VERSION ${CPACK_PACKAGE_VERSION})
|
||||
if(@COMPILE_HIP_ATP_MARKER@)
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, rocm-profiler, comgr >= 1.1")
|
||||
else()
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, comgr >= 1.1")
|
||||
endif()
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "hip-base = ${HIP_BASE_VERSION}, ${HCC_PACKAGE_NAME} = @HCC_PACKAGE_VERSION@, comgr >= 1.1")
|
||||
set(CPACK_RPM_PACKAGE_OBSOLETES "hip_hcc")
|
||||
set(CPACK_RPM_PACKAGE_CONFLICTS "hip_hcc")
|
||||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt")
|
||||
|
||||
@@ -10,7 +10,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
|
||||
|
||||
if(NOT HIP_RUNTIME STREQUAL "vdi")
|
||||
if(NOT HIP_RUNTIME MATCHES "VDI")
|
||||
# Import target "hip::hip_hcc_static" for configuration "Release"
|
||||
set_property(TARGET hip::hip_hcc_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
if(HIP_COMPILER STREQUAL "clang")
|
||||
@@ -28,24 +28,31 @@ if(NOT HIP_RUNTIME STREQUAL "vdi")
|
||||
list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc_static )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc_static "${_IMPORT_PREFIX}/lib/libhip_hcc_static.a" )
|
||||
|
||||
endif()
|
||||
# Import target "hip::hip_hcc" for configuration "Release"
|
||||
set_property(TARGET hip::hip_hcc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
if(HIP_COMPILER STREQUAL "clang")
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libhip_hcc.so"
|
||||
IMPORTED_SONAME_RELEASE "libhip_hcc.so"
|
||||
)
|
||||
else()
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hcc::hccrt;hcc::hc_am"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libhip_hcc.so"
|
||||
IMPORTED_SONAME_RELEASE "libhip_hcc.so"
|
||||
)
|
||||
endif()
|
||||
# Import target "hip::hip_hcc" for configuration "Release"
|
||||
set_property(TARGET hip::hip_hcc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
if(HIP_COMPILER STREQUAL "clang")
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libhip_hcc.so"
|
||||
IMPORTED_SONAME_RELEASE "libhip_hcc.so")
|
||||
else()
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hcc::hccrt;hcc::hc_am"
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libhip_hcc.so"
|
||||
IMPORTED_SONAME_RELEASE "libhip_hcc.so")
|
||||
endif()
|
||||
list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc "${_IMPORT_PREFIX}/lib/libhip_hcc.so" )
|
||||
|
||||
list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc )
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc "${_IMPORT_PREFIX}/lib/libhip_hcc.so" )
|
||||
else()
|
||||
|
||||
set_property(TARGET hip::amdhip64 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(hip::amdhip64 PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libamdhip64.so"
|
||||
IMPORTED_SONAME_RELEASE "libamdhip64.so")
|
||||
list(APPEND _IMPORT_CHECK_TARGETS hip::amdhip64)
|
||||
list(APPEND _IMPORT_CHECK_FILES_FOR_hip::amdhip64 "${_IMPORT_PREFIX}/lib/libamdhip64.so" )
|
||||
|
||||
endif()
|
||||
|
||||
# Commands beyond this point should not need to know the version.
|
||||
set(CMAKE_IMPORT_FILE_VERSION)
|
||||
|
||||
@@ -16,8 +16,8 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
|
||||
set(_targetsDefined)
|
||||
set(_targetsNotDefined)
|
||||
set(_expectedTargets)
|
||||
if(HIP_RUNTIME STREQUAL "vdi")
|
||||
foreach(_expectedTarget hip::hip_hcc hip::host hip::device)
|
||||
if(HIP_RUNTIME MATCHES "VDI")
|
||||
foreach(_expectedTarget hip::amdhip64 hip::host hip::device)
|
||||
else()
|
||||
foreach(_expectedTarget hip:hip_hcc_static hip::hip_hcc hip::host hip::device)
|
||||
endif()
|
||||
@@ -52,7 +52,7 @@ get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
|
||||
|
||||
# Create imported target hip::hip_hcc_static
|
||||
if( NOT HIP_RUNTIME STREQUAL "vdi")
|
||||
if( NOT HIP_RUNTIME MATCHES "VDI")
|
||||
add_library(hip::hip_hcc_static STATIC IMPORTED)
|
||||
endif()
|
||||
|
||||
@@ -68,26 +68,39 @@ find_path(HSA_HEADER hsa/hsa.h
|
||||
if (HSA_HEADER-NOTFOUND)
|
||||
message (FATAL_ERROR "HSA header not found! ROCM_PATH environment not set")
|
||||
endif()
|
||||
if(NOT HIP_RUNTIME STREQUAL "vdi")
|
||||
if(HIP_RUNTIME MATCHES "VDI")
|
||||
# Create imported target hip::amdhip64
|
||||
add_library(hip::amdhip64 SHARED IMPORTED)
|
||||
|
||||
set_target_properties(hip::amdhip64 PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
)
|
||||
else()
|
||||
set_target_properties(hip::hip_hcc_static PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}")
|
||||
|
||||
# Create imported target hip::hip_hcc
|
||||
add_library(hip::hip_hcc SHARED IMPORTED)
|
||||
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Create imported target hip::hip_hcc
|
||||
add_library(hip::hip_hcc SHARED IMPORTED)
|
||||
|
||||
set_target_properties(hip::hip_hcc PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${HSA_HEADER}"
|
||||
)
|
||||
|
||||
# Create imported target hip::host
|
||||
add_library(hip::host INTERFACE IMPORTED)
|
||||
|
||||
set_target_properties(hip::host PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "hip::hip_hcc"
|
||||
)
|
||||
if(HIP_RUNTIME MATCHES "VDI")
|
||||
set_target_properties(hip::host PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "hip::amdhip64")
|
||||
else()
|
||||
set_target_properties(hip::host PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "hip::hip_hcc")
|
||||
endif()
|
||||
|
||||
|
||||
# Create imported target hip::device
|
||||
add_library(hip::device INTERFACE IMPORTED)
|
||||
|
||||
@@ -3,9 +3,8 @@ project(hip_vdi)
|
||||
|
||||
install(FILES @PROJECT_BINARY_DIR@/lib/libamdhip64.so DESTINATION lib)
|
||||
install(FILES @PROJECT_BINARY_DIR@/lib/libhip_hcc.so DESTINATION lib)
|
||||
if(NOT @HIP_COMPILER@ STREQUAL "clang")
|
||||
install(FILES @PROJECT_BINARY_DIR@/libhiprtc.so DESTINATION lib)
|
||||
endif()
|
||||
install(FILES @PROJECT_BINARY_DIR@/lib/libhiprtc.so DESTINATION lib)
|
||||
|
||||
install(FILES @PROJECT_BINARY_DIR@/.hipInfo DESTINATION lib)
|
||||
install(FILES @PROJECT_BINARY_DIR@/hip-config.cmake @PROJECT_BINARY_DIR@/hip-config-version.cmake DESTINATION lib/cmake/hip)
|
||||
install(FILES @hip_SOURCE_DIR@/packaging/hip-targets.cmake @hip_SOURCE_DIR@/packaging/hip-targets-release.cmake DESTINATION lib/cmake/hip)
|
||||
|
||||
@@ -4,16 +4,17 @@ ifeq (,$(HIP_PATH))
|
||||
endif
|
||||
HIPCC=$(HIP_PATH)/bin/hipcc -std=c++11
|
||||
|
||||
EXE=hipDispatchLatency
|
||||
|
||||
CXXFLAGS = -O3
|
||||
|
||||
all: test_kernel.code ${EXE}
|
||||
all: test_kernel.code hipDispatchLatency.out hipDispatchEnqueueRateMT.out
|
||||
|
||||
$(EXE): hipDispatchLatency.cpp
|
||||
hipDispatchLatency.out: hipDispatchLatency.cpp
|
||||
$(HIPCC) $(CXXFLAGS) hipDispatchLatency.cpp -o $@
|
||||
|
||||
hipDispatchEnqueueRateMT.out: hipDispatchEnqueueRateMT.cpp
|
||||
$(HIPCC) $(CXXFLAGS) hipDispatchEnqueueRateMT.cpp -o $@
|
||||
|
||||
test_kernel.code: test_kernel.cpp
|
||||
$(HIP_PATH)/bin/hipcc --genco $(GENCO_FLAGS) $^ -o $@
|
||||
clean:
|
||||
rm -f *.o $(EXE)
|
||||
rm -f *.o *.out
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
Copyright (c) 2020-present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "hip/hip_runtime.h"
|
||||
#ifdef __HIP_PLATFORM_HCC__
|
||||
#include "hip/hip_ext.h"
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#include <functional>
|
||||
|
||||
#define NUM_GROUPS 1
|
||||
#define GROUP_SIZE 1
|
||||
#define WARMUP_RUN_COUNT 10
|
||||
#define TIMING_RUN_COUNT 100
|
||||
#define TOTAL_RUN_COUNT WARMUP_RUN_COUNT + TIMING_RUN_COUNT
|
||||
|
||||
__global__ void EmptyKernel() {}
|
||||
|
||||
// Helper to print various timing metrics
|
||||
void print_timing(std::string test, std::array<float, TOTAL_RUN_COUNT> &results, int batch = 1)
|
||||
{
|
||||
|
||||
float total_us = 0.0f, mean_us = 0.0f, stddev_us = 0.0f;
|
||||
|
||||
// remove top outliers due to nature of variability across large number of multi-threaded runs
|
||||
std::sort(results.begin(), results.end(), std::greater<float>());
|
||||
auto start_iter = std::next(results.begin(), WARMUP_RUN_COUNT);
|
||||
auto end_iter = results.end();
|
||||
|
||||
// mean
|
||||
std::for_each(start_iter, end_iter, [&](const float &run_ms) {
|
||||
total_us += (run_ms * 1000) / batch;
|
||||
});
|
||||
mean_us = total_us / TIMING_RUN_COUNT;
|
||||
|
||||
// stddev
|
||||
total_us = 0;
|
||||
std::for_each(start_iter, end_iter, [&](const float &run_ms) {
|
||||
float dev_us = ((run_ms * 1000) / batch) - mean_us;
|
||||
total_us += dev_us * dev_us;
|
||||
});
|
||||
stddev_us = sqrt(total_us / TIMING_RUN_COUNT);
|
||||
|
||||
printf("\n %s: %.1f us, std: %.1f us\n", test.c_str(), mean_us, stddev_us);
|
||||
}
|
||||
|
||||
// Measure time taken to enqueue a kernel on the GPU using hipModuleLaunchKernel
|
||||
void hipModuleLaunchKernel_enqueue_rate(std::atomic_int* shared, int max_threads)
|
||||
{
|
||||
//resources necessary for this thread
|
||||
hipStream_t stream;
|
||||
hipStreamCreate(&stream);
|
||||
hipModule_t module;
|
||||
hipFunction_t function;
|
||||
hipModuleLoad(&module, "test_kernel.code");
|
||||
hipModuleGetFunction(&function, module, "test");
|
||||
void* kernel_params = nullptr;
|
||||
std::array<float, TOTAL_RUN_COUNT> results;
|
||||
|
||||
//synchronize all threads, before running
|
||||
int tid = shared->fetch_add(1, std::memory_order_release);
|
||||
while (max_threads != shared->load(std::memory_order_acquire)) {}
|
||||
|
||||
for (auto i = 0; i < TOTAL_RUN_COUNT; ++i) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
hipModuleLaunchKernel(function, 1, 1, 1, 1, 1, 1, 0, stream, &kernel_params, nullptr);
|
||||
auto stop = std::chrono::high_resolution_clock::now();
|
||||
results[i] = std::chrono::duration<double, std::milli>(stop - start).count();
|
||||
}
|
||||
print_timing("Thread ID : " + std::to_string(tid) + " , " + "hipModuleLaunchKernel enqueue rate", results);
|
||||
}
|
||||
|
||||
// Measure time taken to enqueue a kernel on the GPU using hipLaunchKernelGGL
|
||||
void hipLaunchKernelGGL_enqueue_rate(std::atomic_int* shared, int max_threads)
|
||||
{
|
||||
//resources necessary for this thread
|
||||
hipStream_t stream;
|
||||
hipStreamCreate(&stream);
|
||||
std::array<float, TOTAL_RUN_COUNT> results;
|
||||
|
||||
//synchronize all threads, before running
|
||||
int tid = shared->fetch_add(1, std::memory_order_release);
|
||||
while (max_threads != shared->load(std::memory_order_acquire)) {}
|
||||
|
||||
for (auto i = 0; i < TOTAL_RUN_COUNT; ++i) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
hipLaunchKernelGGL((EmptyKernel), dim3(NUM_GROUPS), dim3(GROUP_SIZE), 0, stream);
|
||||
auto stop = std::chrono::high_resolution_clock::now();
|
||||
results[i] = std::chrono::duration<double, std::milli>(stop - start).count();
|
||||
}
|
||||
print_timing("Thread ID : " + std::to_string(tid) + " , " + "hipLaunchKernelGGL enqueue rate", results);
|
||||
}
|
||||
|
||||
// Simple thread pool
|
||||
struct thread_pool {
|
||||
thread_pool(int total_threads) : max_threads(total_threads) {}
|
||||
void start(std::function<void(std::atomic_int*, int)> f) {
|
||||
for (int i = 0; i < max_threads; ++i) {
|
||||
threads.push_back(std::async(std::launch::async, f, &shared, max_threads));
|
||||
}
|
||||
}
|
||||
void finish() {
|
||||
for (auto&&thread : threads) {
|
||||
thread.get();
|
||||
}
|
||||
threads.clear();
|
||||
shared = {0};
|
||||
}
|
||||
~thread_pool() {
|
||||
finish();
|
||||
}
|
||||
private:
|
||||
std::atomic_int shared {0};
|
||||
std::vector<std::future<void>> threads;
|
||||
int max_threads = 1;
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
std::cerr << "Run test as 'hipDispatchEnqueueRateMT <num_threads> <0-hipModuleLaunchKernel /1-hipLaunchKernelGGL>'\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
int max_threads = atoi(argv[1]);
|
||||
int run_module_test = atoi(argv[2]);
|
||||
if(max_threads < 1 || run_module_test < 0 || run_module_test > 1) {
|
||||
std::cerr << "Invalid Input.\n";
|
||||
std::cerr << "Run test as 'hipDispatchEnqueueRateMT <num_threads> <0-hipModuleLaunchKernel /1-hipLaunchKernelGGL>'\n";
|
||||
return -1;
|
||||
}
|
||||
thread_pool task(max_threads);
|
||||
|
||||
if(run_module_test == 0) {
|
||||
task.start(hipModuleLaunchKernel_enqueue_rate);
|
||||
task.finish();
|
||||
} else {
|
||||
task.start(hipLaunchKernelGGL_enqueue_rate);
|
||||
task.finish();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+247
-10
@@ -28,6 +28,7 @@ THE SOFTWARE.
|
||||
#include "hip_hcc_internal.h"
|
||||
#include "hip_fatbin.h"
|
||||
#include "trace_helper.h"
|
||||
#include "program_state.inl"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC visibility push (default)
|
||||
@@ -94,8 +95,10 @@ __hipRegisterFatBinary(const void* data)
|
||||
agent);
|
||||
|
||||
if (module->executable.handle) {
|
||||
modules->at(deviceId) = module;
|
||||
tprintf(DB_FB, "Loaded code object for %s\n", name);
|
||||
hip_impl::program_state_impl::read_kernarg_metadata(image, module->kernargs);
|
||||
modules->at(deviceId) = module;
|
||||
|
||||
tprintf(DB_FB, "Loaded code object for %s, args size=%ld\n", name, module->kernargs.size());
|
||||
} else {
|
||||
fprintf(stderr, "Failed to load code object for %s\n", name);
|
||||
abort();
|
||||
@@ -157,16 +160,215 @@ extern "C" void __hipRegisterFunction(
|
||||
g_functions.insert(std::make_pair(hostFunction, std::move(functions)));
|
||||
}
|
||||
|
||||
static inline const char* hsa_strerror(hsa_status_t status) {
|
||||
const char* str = nullptr;
|
||||
if (hsa_status_string(status, &str) == HSA_STATUS_SUCCESS) {
|
||||
return str;
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
struct RegisteredVar {
|
||||
public:
|
||||
RegisteredVar(): size_(0), devicePtr_(nullptr) {}
|
||||
~RegisteredVar() {}
|
||||
|
||||
static inline const char* hsa_strerror(hsa_status_t status) {
|
||||
const char* str = nullptr;
|
||||
if (hsa_status_string(status, &str) == HSA_STATUS_SUCCESS) {
|
||||
return str;
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
hipDeviceptr_t getdeviceptr() const { return devicePtr_; };
|
||||
size_t getvarsize() const { return size_; };
|
||||
|
||||
size_t size_; // Size of the variable
|
||||
hipDeviceptr_t devicePtr_; //Device Memory Address of the variable.
|
||||
};
|
||||
|
||||
struct DeviceVar {
|
||||
void* shadowVptr;
|
||||
std::string hostVar;
|
||||
size_t size;
|
||||
std::vector<hipModule_t>* modules;
|
||||
std::vector<RegisteredVar> rvars;
|
||||
bool dyn_undef;
|
||||
};
|
||||
|
||||
std::unordered_multimap<std::string, DeviceVar > g_vars;
|
||||
|
||||
//The logic follows PlatformState::getGlobalVar in VDI RT
|
||||
static DeviceVar* findVar(std::string hostVar, int deviceId, hipModule_t hmod) {
|
||||
DeviceVar* dvar = nullptr;
|
||||
if (hmod != nullptr) {
|
||||
// If module is provided, then get the var only from that module
|
||||
auto var_range = g_vars.equal_range(hostVar);
|
||||
for (auto it = var_range.first; it != var_range.second; ++it) {
|
||||
if ((*it->second.modules)[deviceId] == hmod) {
|
||||
dvar = &(it->second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If var count is < 2, return the var
|
||||
if (g_vars.count(hostVar) < 2) {
|
||||
auto it = g_vars.find(hostVar);
|
||||
dvar = ((it == g_vars.end()) ? nullptr : &(it->second));
|
||||
} else {
|
||||
// If var count is > 2, return the original var,
|
||||
// if original var count != 1, return g_vars.end()/Invalid
|
||||
size_t orig_global_count = 0;
|
||||
auto var_range = g_vars.equal_range(hostVar);
|
||||
for (auto it = var_range.first; it != var_range.second; ++it) {
|
||||
// when dyn_undef is set, it is a shadow var
|
||||
if (it->second.dyn_undef == false) {
|
||||
++orig_global_count;
|
||||
dvar = &(it->second);
|
||||
}
|
||||
}
|
||||
dvar = ((orig_global_count == 1) ? dvar : nullptr);
|
||||
}
|
||||
}
|
||||
return dvar;
|
||||
}
|
||||
|
||||
hipError_t ihipGetGlobalVar(hipDeviceptr_t* dev_ptr, size_t* size_ptr,
|
||||
const char* hostVar, hipModule_t hmod) {
|
||||
GET_TLS();
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
|
||||
if (!ctx) return hipErrorInvalidValue;
|
||||
|
||||
auto device = ctx->getDevice();
|
||||
|
||||
if (!device) return hipErrorInvalidValue;
|
||||
|
||||
ihipDevice_t* currentDevice = ihipGetDevice(device->_deviceId);
|
||||
|
||||
if (!currentDevice) return hipErrorInvalidValue;
|
||||
|
||||
int deviceId = device->_deviceId;
|
||||
|
||||
DeviceVar* dvar = findVar(std::string(hostVar), deviceId, hmod);
|
||||
if (dvar == nullptr) return hipErrorInvalidValue;
|
||||
|
||||
if (dvar->rvars[deviceId].getdeviceptr() == nullptr) return hipErrorInvalidValue;
|
||||
|
||||
*size_ptr = dvar->rvars[deviceId].getvarsize();
|
||||
*dev_ptr = dvar->rvars[deviceId].getdeviceptr();
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
static bool createGlobalVarObj(const hsa_executable_t& hsaExecutable, const hsa_agent_t& hasAgent,
|
||||
const char* global_name, void** device_pptr, size_t* bytes) {
|
||||
hsa_status_t status = HSA_STATUS_SUCCESS;
|
||||
hsa_symbol_kind_t sym_type;
|
||||
hsa_executable_symbol_t global_symbol;
|
||||
std::string buildLog;
|
||||
|
||||
/* Find HSA Symbol by name */
|
||||
status = hsa_executable_get_symbol_by_name(hsaExecutable, global_name, &hasAgent,
|
||||
&global_symbol);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog += "Error: Failed to find the Symbol by Name: ";
|
||||
buildLog += hsa_strerror(status);
|
||||
tprintf(DB_FB, "createGlobalVarObj: %s\n", buildLog.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Find HSA Symbol Type */
|
||||
status = hsa_executable_symbol_get_info(global_symbol, HSA_EXECUTABLE_SYMBOL_INFO_TYPE,
|
||||
&sym_type);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog += "Error: Failed to find the Symbol Type : ";
|
||||
buildLog += hsa_strerror(status);
|
||||
tprintf(DB_FB, "createGlobalVarObj: %s\n", buildLog.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Make sure symbol type is VARIABLE */
|
||||
if (sym_type != HSA_SYMBOL_KIND_VARIABLE) {
|
||||
buildLog += "Error: Symbol is not of type VARIABLE : ";
|
||||
buildLog += hsa_strerror(status);
|
||||
tprintf(DB_FB, "createGlobalVarObj: %s\n", buildLog.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Retrieve the size of the variable */
|
||||
status = hsa_executable_symbol_get_info(global_symbol, HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_SIZE, bytes);
|
||||
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog += "Error: Failed to retrieve the Symbol Size : ";
|
||||
buildLog += hsa_strerror(status);
|
||||
tprintf(DB_FB, "createGlobalVarObj: %s\n", buildLog.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Find HSA Symbol Address */
|
||||
status = hsa_executable_symbol_get_info(global_symbol,
|
||||
HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_ADDRESS, device_pptr);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog += "Error: Failed to find the Symbol Address : ";
|
||||
buildLog += hsa_strerror(status);
|
||||
tprintf(DB_FB, "createGlobalVarObj: %s\n", buildLog.c_str());
|
||||
return false;
|
||||
} else {
|
||||
tprintf(DB_FB, "createGlobalVarObj: var %s : device=%p, size=%zu\n", global_name, *device_pptr, *bytes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Registers a device-side global variable.
|
||||
// For each global variable in device code, there is a corresponding shadow
|
||||
// global variable in host code. The shadow host variable is used to keep
|
||||
// track of the value of the device side global variable between kernel
|
||||
// executions.
|
||||
// The basic logic is taken from VDI RT, but there is much difference.
|
||||
extern "C" void __hipRegisterVar(
|
||||
std::vector<hipModule_t>* modules,
|
||||
char* hostVar,
|
||||
char* deviceVar,
|
||||
const char* deviceName,
|
||||
int ext,
|
||||
int size,
|
||||
int constant,
|
||||
int global)
|
||||
std::vector<hipModule_t>* modules, // The device modules containing code object
|
||||
char* var, // The shadow variable in host code
|
||||
char* hostVar, // Variable name in host code
|
||||
const char* deviceVar, // Variable name in device code
|
||||
int ext, // Whether this variable is external
|
||||
int size, // Size of the variable
|
||||
int constant, // Whether this variable is constant
|
||||
int global) // Unknown, always 0
|
||||
{
|
||||
HIP_INIT_API(__hipRegisterVar, modules, var, hostVar, deviceVar, ext, size, constant, global);
|
||||
|
||||
DeviceVar dvar{var, std::string{ hostVar }, static_cast<size_t>(size), modules,
|
||||
std::vector<RegisteredVar>{ g_deviceCnt }, false };
|
||||
|
||||
for (int deviceId = 0; deviceId < g_deviceCnt; deviceId++) {
|
||||
auto device = ihipGetDevice(deviceId);
|
||||
if(!device) {
|
||||
continue;
|
||||
}
|
||||
hsa_executable_t& executable = (*modules)[deviceId]->executable;
|
||||
hsa_agent_t& agent = g_allAgents[deviceId + 1];
|
||||
size_t bytes = 0;
|
||||
hipDeviceptr_t devicePtr = nullptr;
|
||||
|
||||
bool success = createGlobalVarObj(executable, agent, hostVar, &devicePtr, &bytes);
|
||||
if(!success) {
|
||||
return;
|
||||
}
|
||||
dvar.rvars[deviceId].devicePtr_ = devicePtr;
|
||||
dvar.rvars[deviceId].size_ = bytes;
|
||||
|
||||
hc::AmPointerInfo ptrInfo(nullptr, devicePtr, devicePtr, bytes, device->_acc, true, false);
|
||||
hc::am_memtracker_add(devicePtr, ptrInfo);
|
||||
|
||||
#if USE_APP_PTR_FOR_CTX
|
||||
hc::am_memtracker_update(devicePtr, device->_deviceId, 0u, ihipGetTlsDefaultCtx());
|
||||
#else
|
||||
hc::am_memtracker_update(devicePtr, device->_deviceId, 0u);
|
||||
#endif
|
||||
}
|
||||
g_vars.insert(std::make_pair(std::string(hostVar), dvar));
|
||||
}
|
||||
|
||||
extern "C" void __hipUnregisterFatBinary(std::vector<hipModule_t>* modules)
|
||||
@@ -226,6 +428,41 @@ extern "C" hipError_t __hipPopCallConfiguration(
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
int getCurrentDeviceId()
|
||||
{
|
||||
GET_TLS();
|
||||
|
||||
int deviceId = 0;
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
|
||||
if(!ctx) return deviceId;
|
||||
|
||||
LockedAccessor_CtxCrit_t crit(ctx->criticalData());
|
||||
|
||||
if(crit->_execStack.size() != 0)
|
||||
{
|
||||
auto &exec = crit->_execStack.top();
|
||||
|
||||
if (exec._hStream) {
|
||||
deviceId = exec._hStream->getDevice()->_deviceId;
|
||||
} else if (ctx->getDevice()) {
|
||||
deviceId = ctx->getDevice()->_deviceId;
|
||||
}
|
||||
} else if (ctx->getDevice()) {
|
||||
deviceId = ctx->getDevice()->_deviceId;
|
||||
}
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
hipFunction_t ihipGetDeviceFunction(const void *hostFunction)
|
||||
{
|
||||
int deviceId = getCurrentDeviceId();
|
||||
auto it = g_functions.find(hostFunction);
|
||||
if (it == g_functions.end() || !it->second[deviceId]) {
|
||||
return nullptr;
|
||||
}
|
||||
return it->second[deviceId];
|
||||
}
|
||||
|
||||
hipError_t hipSetupArgument(
|
||||
const void *arg,
|
||||
|
||||
+14
-43
@@ -39,6 +39,7 @@ THE SOFTWARE.
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <hc.hpp>
|
||||
#include <hc_am.hpp>
|
||||
@@ -71,7 +72,6 @@ int HIP_API_BLOCKING = 0;
|
||||
int HIP_PRINT_ENV = 0;
|
||||
int HIP_TRACE_API = 0;
|
||||
std::string HIP_TRACE_API_COLOR("green");
|
||||
int HIP_PROFILE_API = 0;
|
||||
|
||||
// TODO - DB_START/STOP need more testing.
|
||||
std::string HIP_DB_START_API;
|
||||
@@ -149,12 +149,10 @@ uint64_t recordApiTrace(TlsData *tls, std::string* fullStr, const std::string& a
|
||||
|
||||
if ((tid < g_dbStartTriggers.size()) && (apiSeqNum >= g_dbStartTriggers[tid].nextTrigger())) {
|
||||
printf("info: resume profiling at %lu\n", apiSeqNum);
|
||||
RESUME_PROFILING;
|
||||
g_dbStartTriggers.pop_back();
|
||||
};
|
||||
if ((tid < g_dbStopTriggers.size()) && (apiSeqNum >= g_dbStopTriggers[tid].nextTrigger())) {
|
||||
printf("info: stop profiling at %lu\n", apiSeqNum);
|
||||
STOP_PROFILING;
|
||||
g_dbStopTriggers.pop_back();
|
||||
};
|
||||
|
||||
@@ -1294,9 +1292,6 @@ void HipReadEnv() {
|
||||
"executes.");
|
||||
READ_ENV_S(release, HIP_TRACE_API_COLOR, 0,
|
||||
"Color to use for HIP_API. None/Red/Green/Yellow/Blue/Magenta/Cyan/White");
|
||||
READ_ENV_I(release, HIP_PROFILE_API, 0,
|
||||
"Add HIP API markers to ATP file generated with CodeXL. 0x1=short API name, "
|
||||
"0x2=full API name including args.");
|
||||
READ_ENV_S(release, HIP_DB_START_API, 0,
|
||||
"Comma-separated list of tid.api_seq_num for when to start debug and profiling.");
|
||||
READ_ENV_S(release, HIP_DB_STOP_API, 0,
|
||||
@@ -1372,14 +1367,6 @@ void HipReadEnv() {
|
||||
HIP_DB |= 0x1;
|
||||
}
|
||||
|
||||
if (HIP_PROFILE_API && !COMPILE_HIP_ATP_MARKER) {
|
||||
fprintf(stderr,
|
||||
"warning: env var HIP_PROFILE_API=0x%x but COMPILE_HIP_ATP_MARKER=0. (perhaps "
|
||||
"enable COMPILE_HIP_ATP_MARKER in src code before compiling?)\n",
|
||||
HIP_PROFILE_API);
|
||||
HIP_PROFILE_API = 0;
|
||||
}
|
||||
|
||||
if (HIP_DB) {
|
||||
fprintf(stderr, "HIP_DB=0x%x [%s]\n", HIP_DB, HIP_DB_string(HIP_DB).c_str());
|
||||
}
|
||||
@@ -1423,11 +1410,6 @@ void HipReadEnv() {
|
||||
// This function creates a vector with only the GPU accelerators.
|
||||
// It is called with C++11 call_once, which provided thread-safety.
|
||||
void ihipInit() {
|
||||
#if COMPILE_HIP_ATP_MARKER
|
||||
amdtInitializeActivityLogger();
|
||||
amdtScopedMarker("ihipInit", "HIP", NULL);
|
||||
#endif
|
||||
|
||||
|
||||
HipReadEnv();
|
||||
|
||||
@@ -1617,7 +1599,7 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t stream, bool lockAcquired) {
|
||||
|
||||
void ihipPrintKernelLaunch(const char* kernelName, const grid_launch_parm* lp,
|
||||
const hipStream_t stream) {
|
||||
if ((HIP_TRACE_API & (1 << TRACE_KCMD)) || HIP_PROFILE_API ||
|
||||
if ((HIP_TRACE_API & (1 << TRACE_KCMD)) ||
|
||||
(COMPILE_HIP_DB & HIP_TRACE_API)) {
|
||||
GET_TLS();
|
||||
std::stringstream os;
|
||||
@@ -1630,14 +1612,6 @@ void ihipPrintKernelLaunch(const char* kernelName, const grid_launch_parm* lp,
|
||||
std::string fullStr;
|
||||
recordApiTrace(tls, &fullStr, os.str());
|
||||
}
|
||||
|
||||
if (HIP_PROFILE_API == 0x1) {
|
||||
std::string shortAtpString("hipLaunchKernel:");
|
||||
shortAtpString += kernelName;
|
||||
MARKER_BEGIN(shortAtpString.c_str(), "HIP");
|
||||
} else if (HIP_PROFILE_API == 0x2) {
|
||||
MARKER_BEGIN(os.str().c_str(), "HIP");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1696,9 +1670,6 @@ void ihipPostLaunchKernel(const char* kernelName, hipStream_t stream, grid_launc
|
||||
tprintf(DB_SYNC, "ihipPostLaunchKernel, unlocking stream\n");
|
||||
|
||||
stream->lockclose_postKernelCommand(kernelName, lp.av, unlockPostponed);
|
||||
if (HIP_PROFILE_API) {
|
||||
MARKER_END();
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
@@ -1796,6 +1767,8 @@ const char* ihipErrorString(hipError_t hip_error) {
|
||||
return "hipErrorMissingConfiguration";
|
||||
case hipErrorLaunchFailure:
|
||||
return "hipErrorLaunchFailure";
|
||||
case hipErrorCooperativeLaunchTooLarge:
|
||||
return "hipErrorCooperativeLaunchTooLarge";
|
||||
case hipErrorPriorLaunchFailure:
|
||||
return "hipErrorPriorLaunchFailure";
|
||||
case hipErrorLaunchTimeOut:
|
||||
@@ -2478,29 +2451,17 @@ bool ihipStream_t::locked_copy2DAsync(void* dst, const void* src, size_t width,
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Profiler, really these should live elsewhere:
|
||||
hipError_t hipProfilerStart() {
|
||||
HIP_INIT_API(hipProfilerStart);
|
||||
#if COMPILE_HIP_ATP_MARKER
|
||||
amdtResumeProfiling(AMDT_ALL_PROFILING);
|
||||
#endif
|
||||
|
||||
return ihipLogStatus(hipSuccess);
|
||||
};
|
||||
|
||||
|
||||
hipError_t hipProfilerStop() {
|
||||
HIP_INIT_API(hipProfilerStop);
|
||||
#if COMPILE_HIP_ATP_MARKER
|
||||
amdtStopProfiling(AMDT_ALL_PROFILING);
|
||||
#endif
|
||||
|
||||
return ihipLogStatus(hipSuccess);
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// HCC-specific accessor functions:
|
||||
@@ -2540,6 +2501,16 @@ hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view** a
|
||||
// TODO - add a contect sequence number for debug. Print operator<< ctx:0.1 (device.ctx)
|
||||
|
||||
namespace hip_impl {
|
||||
std::unordered_set<std::string>& get_all_gpuarch() {
|
||||
static std::unordered_set<std::string> r{};
|
||||
static std::once_flag init;
|
||||
std::call_once(init, []() {
|
||||
for (int i=0; i < g_deviceCnt; i++){
|
||||
r.insert("hcc-amdgcn-amd-amdhsa--gfx"+std::to_string(g_deviceArray[i]->_props.gcnArch));
|
||||
}});
|
||||
return r;
|
||||
}
|
||||
|
||||
std::vector<hsa_agent_t> all_hsa_agents() {
|
||||
std::vector<hsa_agent_t> r{};
|
||||
std::vector<hc::accelerator> visible_accelerators;
|
||||
|
||||
+25
-40
@@ -33,7 +33,7 @@ THE SOFTWARE.
|
||||
#include "hip_prof_api.h"
|
||||
#include "hip_util.h"
|
||||
#include "env.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#if (__hcc_workweek__ < 16354)
|
||||
#error("This version of HIP requires a newer version of HCC.");
|
||||
@@ -63,7 +63,6 @@ extern int HIP_LAUNCH_BLOCKING;
|
||||
extern int HIP_API_BLOCKING;
|
||||
|
||||
extern int HIP_PRINT_ENV;
|
||||
extern int HIP_PROFILE_API;
|
||||
// extern int HIP_TRACE_API;
|
||||
extern int HIP_ATP;
|
||||
extern int HIP_DB;
|
||||
@@ -250,34 +249,6 @@ extern const char* API_COLOR_END;
|
||||
// Must be enabled at runtime with HIP_TRACE_API
|
||||
#define COMPILE_HIP_TRACE_API 0x3
|
||||
|
||||
|
||||
// Compile code that generates trace markers for CodeXL ATP at HIP function begin/end.
|
||||
// ATP is standard CodeXL format that includes timestamps for kernels, HSA RT APIs, and HIP APIs.
|
||||
#ifndef COMPILE_HIP_ATP_MARKER
|
||||
#define COMPILE_HIP_ATP_MARKER 0
|
||||
#endif
|
||||
|
||||
|
||||
// Compile support for trace markers that are displayed on CodeXL GUI at start/stop of each function
|
||||
// boundary.
|
||||
// TODO - currently we print the trace message at the beginning. if we waited, we could also
|
||||
// tls->tidInfo return codes, and any values returned through ptr-to-args (ie the pointers allocated
|
||||
// by hipMalloc).
|
||||
#if COMPILE_HIP_ATP_MARKER
|
||||
#include "CXLActivityLogger.h"
|
||||
#define MARKER_BEGIN(markerName, group) amdtBeginMarker(markerName, group, nullptr);
|
||||
#define MARKER_END() amdtEndMarker();
|
||||
#define RESUME_PROFILING amdtResumeProfiling(AMDT_ALL_PROFILING);
|
||||
#define STOP_PROFILING amdtStopProfiling(AMDT_ALL_PROFILING);
|
||||
#else
|
||||
// Swallow scoped markers:
|
||||
#define MARKER_BEGIN(markerName, group)
|
||||
#define MARKER_END()
|
||||
#define RESUME_PROFILING
|
||||
#define STOP_PROFILING
|
||||
#endif
|
||||
|
||||
|
||||
//---
|
||||
// HIP Trace modes - use with HIP_TRACE_API=...
|
||||
#define TRACE_ALL 0 // 0x01
|
||||
@@ -336,22 +307,17 @@ static inline uint64_t getTicks() { return hc::get_system_ticks(); }
|
||||
//---
|
||||
extern uint64_t recordApiTrace(TlsData *tls, std::string* fullStr, const std::string& apiStr);
|
||||
|
||||
#if COMPILE_HIP_ATP_MARKER || (COMPILE_HIP_TRACE_API & 0x1)
|
||||
#if (COMPILE_HIP_TRACE_API & 0x1)
|
||||
#define API_TRACE(forceTrace, ...) \
|
||||
GET_TLS(); \
|
||||
uint64_t hipApiStartTick = 0; \
|
||||
{ \
|
||||
tls->tidInfo.incApiSeqNum(); \
|
||||
if (forceTrace || \
|
||||
(HIP_PROFILE_API || (COMPILE_HIP_DB && (HIP_TRACE_API & (1 << TRACE_ALL))))) { \
|
||||
(COMPILE_HIP_DB && (HIP_TRACE_API & (1 << TRACE_ALL)))) { \
|
||||
std::string apiStr = std::string(__func__) + " (" + ToString(__VA_ARGS__) + ')'; \
|
||||
std::string fullStr; \
|
||||
hipApiStartTick = recordApiTrace(tls, &fullStr, apiStr); \
|
||||
if (HIP_PROFILE_API == 0x1) { \
|
||||
MARKER_BEGIN(__func__, "HIP") \
|
||||
} else if (HIP_PROFILE_API == 0x2) { \
|
||||
MARKER_BEGIN(fullStr.c_str(), "HIP"); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -398,9 +364,6 @@ extern uint64_t recordApiTrace(TlsData *tls, std::string* fullStr, const std::st
|
||||
tls->tidInfo.apiSeqNum(), __func__, localHipStatus, \
|
||||
ihipErrorString(localHipStatus), ticks, API_COLOR_END); \
|
||||
} \
|
||||
if (HIP_PROFILE_API) { \
|
||||
MARKER_END(); \
|
||||
} \
|
||||
localHipStatus; \
|
||||
})
|
||||
|
||||
@@ -1019,6 +982,18 @@ hipStream_t ihipSyncAndResolveStream(hipStream_t, bool lockAcquired = 0);
|
||||
hipError_t ihipStreamSynchronize(TlsData *tls, hipStream_t stream);
|
||||
void ihipStreamCallbackHandler(ihipStreamCallback_t* cb);
|
||||
|
||||
/**
|
||||
* @brief Copies the memory address and size of symbol @p symbolName
|
||||
*
|
||||
* @param[in] symbolName - Symbol on device
|
||||
* @param[out] devPtr - Pointer to a pointer to the memory referred to by the symbol
|
||||
* @param[out] size - Pointer to the size of the symbol
|
||||
* @return #hipSuccess, #hipErrorNotInitialized, #hipErrorNotFound, #hipErrorInvalidValue
|
||||
*
|
||||
*/
|
||||
hipError_t ihipGetGlobalVar(hipDeviceptr_t* dev_ptr, size_t* size_ptr, const char* hostVar,
|
||||
hipModule_t hmod = nullptr);
|
||||
|
||||
// Stream printf functions:
|
||||
inline std::ostream& operator<<(std::ostream& os, const ihipStream_t& s) {
|
||||
os << "stream:";
|
||||
@@ -1104,4 +1079,14 @@ static inline ihipCtx_t* iihipGetTlsDefaultCtx(TlsData* tls) {
|
||||
return tls->defaultCtx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get device function from host kernel function pointer
|
||||
* Needed only for clang + HIP-HCC RT
|
||||
*
|
||||
* @param [in] hostFunction host kernel function pointer
|
||||
*
|
||||
* @returns hipFuntion_t, nullptr
|
||||
*/
|
||||
hipFunction_t ihipGetDeviceFunction(const void *hostFunction);
|
||||
|
||||
#endif
|
||||
|
||||
+175
-160
@@ -37,7 +37,6 @@ __device__ uint32_t __hip_device_page_flag[__HIP_NUM_PAGES];
|
||||
namespace hip_internal {
|
||||
|
||||
namespace {
|
||||
|
||||
inline
|
||||
const char* hsa_to_string(hsa_status_t err) noexcept
|
||||
{
|
||||
@@ -140,6 +139,8 @@ namespace {
|
||||
return r;
|
||||
}()};
|
||||
|
||||
constexpr std::uint32_t is_cpu_owned{UINT32_MAX};
|
||||
|
||||
inline
|
||||
hsa_amd_pointer_info_t info(const void* p)
|
||||
{
|
||||
@@ -149,13 +150,14 @@ namespace {
|
||||
const_cast<void*>(p), &r, nullptr, nullptr, nullptr),
|
||||
__FILE__, __func__, __LINE__);
|
||||
|
||||
r.size = is_large_BAR || (type(r.agentOwner) == HSA_DEVICE_TYPE_CPU) ?
|
||||
UINT32_MAX : sizeof(hsa_amd_pointer_info_t);
|
||||
if (type(r.agentOwner) == HSA_DEVICE_TYPE_CPU) r.size = is_cpu_owned;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
constexpr size_t staging_sz{4 * 1024 * 1024}; // 2 Pages.
|
||||
constexpr size_t staging_sz{4 * 1024 * 1024}; // 2 Pages.
|
||||
constexpr size_t max_h2d_std_memcpy_sz{8 * 1024}; // 8 KiB.
|
||||
constexpr size_t max_d2h_std_memcpy_sz{64}; // 1 cacheline.
|
||||
|
||||
thread_local const std::unique_ptr<void, void (*)(void *)> staging_buffer{
|
||||
[]() {
|
||||
@@ -202,7 +204,7 @@ namespace {
|
||||
} // Unnamed namespace.
|
||||
|
||||
inline
|
||||
void do_copy(void* __restrict dst, const void* __restrict src, std::size_t n,
|
||||
void do_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
hsa_agent_t da, hsa_agent_t sa) {
|
||||
hsa_signal_silent_store_relaxed(copy_signal, 1);
|
||||
throwing_result_check(
|
||||
@@ -224,14 +226,20 @@ void do_std_memcpy(
|
||||
inline
|
||||
void d2h_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
hsa_amd_pointer_info_t si) {
|
||||
// TODO: characterise direct largeBAR reads from agent-allocated memory.
|
||||
// if (si.size == UINT32_MAX) {
|
||||
// return do_std_memcpy(dst, src, n);
|
||||
// }
|
||||
|
||||
const auto di{info(dst)};
|
||||
const auto is_locked{di.type == HSA_EXT_POINTER_TYPE_LOCKED};
|
||||
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_LOCKED) {
|
||||
if (!is_locked && si.size == is_cpu_owned) {
|
||||
return do_std_memcpy(dst, src, n);
|
||||
}
|
||||
if (!is_locked && is_large_BAR && n <= max_d2h_std_memcpy_sz) {
|
||||
return do_std_memcpy(dst, src, n);
|
||||
}
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_HSA) {
|
||||
return do_copy(dst, src, n, si.agentOwner, si.agentOwner);
|
||||
}
|
||||
|
||||
if (is_locked) {
|
||||
dst = static_cast<char*>(di.agentBaseAddress) +
|
||||
(static_cast<char*>(dst) -
|
||||
static_cast<char*>(di.hostBaseAddress));
|
||||
@@ -247,7 +255,7 @@ void d2h_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
|
||||
throwing_result_check(hsa_amd_memory_lock(dst, n, &si.agentOwner, 1,
|
||||
const_cast<void**>(&dst)),
|
||||
__FILE__, __func__, __LINE__);
|
||||
__FILE__, __func__, __LINE__);
|
||||
|
||||
do_copy(dst, src, n, si.agentOwner, si.agentOwner);
|
||||
}
|
||||
@@ -256,16 +264,23 @@ void d2h_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
inline
|
||||
void h2d_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
hsa_amd_pointer_info_t di) {
|
||||
if (di.size == UINT32_MAX) {
|
||||
const auto si{info(const_cast<void*>(src))};
|
||||
const auto is_locked{si.type == HSA_EXT_POINTER_TYPE_LOCKED};
|
||||
|
||||
if (!is_locked && di.size == is_cpu_owned) {
|
||||
return do_std_memcpy(dst, src, n);
|
||||
}
|
||||
if (!is_locked && is_large_BAR && n <= max_h2d_std_memcpy_sz) {
|
||||
return do_std_memcpy(dst, src, n);
|
||||
}
|
||||
if (si.type == HSA_EXT_POINTER_TYPE_HSA) {
|
||||
return do_copy(dst, src, n, di.agentOwner, di.agentOwner);
|
||||
}
|
||||
|
||||
const auto si{info(const_cast<void*>(src))};
|
||||
|
||||
if (si.type == HSA_EXT_POINTER_TYPE_LOCKED) {
|
||||
if (is_locked) {
|
||||
src = static_cast<char*>(si.agentBaseAddress) +
|
||||
(static_cast<const char*>(src) -
|
||||
static_cast<char*>(si.hostBaseAddress));
|
||||
(static_cast<const char*>(src) -
|
||||
static_cast<char*>(si.hostBaseAddress));
|
||||
do_copy(dst, src, n, di.agentOwner, di.agentOwner);
|
||||
}
|
||||
else if (n <= staging_sz) {
|
||||
@@ -279,7 +294,7 @@ void h2d_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
throwing_result_check(hsa_amd_memory_lock(const_cast<void*>(src), n,
|
||||
&di.agentOwner, 1,
|
||||
const_cast<void**>(&src)),
|
||||
__FILE__, __func__, __LINE__);
|
||||
__FILE__, __func__, __LINE__);
|
||||
|
||||
do_copy(dst, src, n, di.agentOwner, di.agentOwner);
|
||||
}
|
||||
@@ -288,69 +303,36 @@ void h2d_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
inline
|
||||
void generic_copy(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
hsa_amd_pointer_info_t di, hsa_amd_pointer_info_t si) {
|
||||
if (di.size == UINT32_MAX && si.size == UINT32_MAX) {
|
||||
if (di.size == is_cpu_owned && si.size == is_cpu_owned) {
|
||||
return do_std_memcpy(dst, src, n);
|
||||
}
|
||||
if (di.size == is_cpu_owned) return d2h_copy(dst, src, n, si);
|
||||
if (si.size == is_cpu_owned) return h2d_copy(dst, src, n, di);
|
||||
|
||||
std::unique_ptr<void, void (*)(void*)> lck0{
|
||||
nullptr, [](void* p) { hsa_amd_memory_unlock(p); }};
|
||||
std::unique_ptr<void, void (*)(void*)> lck1{nullptr, lck0.get_deleter()};
|
||||
throwing_result_check(hsa_amd_agents_allow_access(1u, &si.agentOwner,
|
||||
nullptr,
|
||||
di.agentBaseAddress),
|
||||
__FILE__, __func__, __LINE__);
|
||||
|
||||
switch (si.type) {
|
||||
case HSA_EXT_POINTER_TYPE_HSA:
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_HSA) {
|
||||
hsa_memory_copy(dst, src, n);
|
||||
return; // TODO: do_copy(dst, src, n, di.agentOwner, si.agentOwner);
|
||||
}
|
||||
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_UNKNOWN ||
|
||||
di.type == HSA_EXT_POINTER_TYPE_LOCKED) {
|
||||
return d2h_copy(dst, src, n, si);
|
||||
}
|
||||
break;
|
||||
case HSA_EXT_POINTER_TYPE_LOCKED:
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_UNKNOWN) {
|
||||
std::memcpy(dst, si.hostBaseAddress, n);
|
||||
|
||||
return;
|
||||
}
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_LOCKED) {
|
||||
std::memcpy(di.hostBaseAddress, si.hostBaseAddress, n);
|
||||
|
||||
return;
|
||||
}
|
||||
src = si.agentBaseAddress;
|
||||
si.agentOwner = di.agentOwner;
|
||||
break;
|
||||
case HSA_EXT_POINTER_TYPE_UNKNOWN:
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_UNKNOWN) {
|
||||
std::memcpy(dst, src, n);
|
||||
|
||||
return;
|
||||
}
|
||||
if (di.type == HSA_EXT_POINTER_TYPE_LOCKED) {
|
||||
std::memcpy(di.hostBaseAddress, src, n);
|
||||
|
||||
return;
|
||||
}
|
||||
return h2d_copy(dst, src, n, di);
|
||||
default: do_copy(dst, src, n, di.agentOwner, si.agentOwner); break;
|
||||
}
|
||||
return do_copy(dst, src, n, di.agentOwner, si.agentOwner);
|
||||
}
|
||||
|
||||
inline
|
||||
void memcpy_impl(void* __restrict dst, const void* __restrict src, size_t n,
|
||||
hipMemcpyKind k) noexcept {
|
||||
hipMemcpyKind k) {
|
||||
switch (k) {
|
||||
case hipMemcpyHostToHost: std::memcpy(dst, src, n); break;
|
||||
case hipMemcpyHostToDevice:
|
||||
return is_large_BAR ? do_std_memcpy(dst, src, n)
|
||||
: h2d_copy(dst, src, n, info(dst));
|
||||
case hipMemcpyDeviceToHost:
|
||||
// TODO: characterise direct largeBAR reads from agent-allocated memory.
|
||||
return /*is_large_BAR ? do_std_memcpy(dst, src, n)
|
||||
: */d2h_copy(dst, src, n, info(src));
|
||||
case hipMemcpyDeviceToDevice: hsa_memory_copy(dst, src, n); break;
|
||||
case hipMemcpyHostToDevice: return h2d_copy(dst, src, n, info(dst));
|
||||
case hipMemcpyDeviceToHost: return d2h_copy(dst, src, n, info(src));
|
||||
case hipMemcpyDeviceToDevice: {
|
||||
const auto di{info(dst)};
|
||||
const auto si{info(src)};
|
||||
throwing_result_check(hsa_amd_agents_allow_access(1u, &si.agentOwner,
|
||||
nullptr,
|
||||
di.agentBaseAddress),
|
||||
__FILE__, __func__, __LINE__);
|
||||
return do_copy(dst, src, n, di.agentOwner, si.agentOwner);
|
||||
}
|
||||
default: return generic_copy(dst, src, n, info(dst), info(src));
|
||||
}
|
||||
}
|
||||
@@ -1290,7 +1272,7 @@ hipError_t hipMemcpyToSymbolAsync(void* dst, const void* src, size_t count,
|
||||
if (dst == nullptr) {
|
||||
return ihipLogStatus(hipErrorInvalidSymbol);
|
||||
}
|
||||
|
||||
|
||||
if (kind == hipMemcpyDeviceToHost || kind == hipMemcpyHostToHost) {
|
||||
return ihipLogStatus(hipErrorInvalidMemcpyDirection);
|
||||
} else if (kind == hipMemcpyDeviceToDevice) {
|
||||
@@ -1322,7 +1304,7 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* src, size_t count,
|
||||
if (src == nullptr || dst == nullptr) {
|
||||
return ihipLogStatus(hipErrorInvalidSymbol);
|
||||
}
|
||||
|
||||
|
||||
if (kind == hipMemcpyHostToDevice || kind == hipMemcpyHostToHost) {
|
||||
return ihipLogStatus(hipErrorInvalidMemcpyDirection);
|
||||
} else if (kind == hipMemcpyDeviceToDevice) {
|
||||
@@ -1540,111 +1522,144 @@ hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t
|
||||
return ihipLogStatus(e);
|
||||
}
|
||||
|
||||
int getByteSizeFromFormat(const hipChannelFormatDesc& desc){
|
||||
int byteSize =0;
|
||||
switch (desc.f) {
|
||||
case hipChannelFormatKindUnsigned:
|
||||
switch (desc.x) {
|
||||
case 32:
|
||||
byteSize = sizeof(uint32_t);
|
||||
break;
|
||||
case 16:
|
||||
byteSize = sizeof(uint16_t);
|
||||
break;
|
||||
case 8:
|
||||
byteSize = sizeof(uint8_t);
|
||||
break;
|
||||
default:
|
||||
byteSize = sizeof(uint32_t);
|
||||
}
|
||||
break;
|
||||
case hipChannelFormatKindSigned:
|
||||
switch (desc.x) {
|
||||
case 32:
|
||||
byteSize = sizeof(int32_t);
|
||||
break;
|
||||
case 16:
|
||||
byteSize = sizeof(int16_t);
|
||||
break;
|
||||
case 8:
|
||||
byteSize = sizeof(int8_t);
|
||||
break;
|
||||
default:
|
||||
byteSize = sizeof(int32_t);
|
||||
}
|
||||
break;
|
||||
case hipChannelFormatKindFloat:
|
||||
switch (desc.x) {
|
||||
case 32:
|
||||
byteSize = sizeof(float);
|
||||
break;
|
||||
case 16:
|
||||
byteSize = sizeof(_Float16);
|
||||
break;
|
||||
default:
|
||||
byteSize = sizeof(float);
|
||||
}
|
||||
break;
|
||||
case hipChannelFormatKindNone:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return byteSize;
|
||||
}
|
||||
|
||||
hipError_t ihipMemcpy3D(const struct hipMemcpy3DParms* p, hipStream_t stream, bool isAsync) {
|
||||
hipError_t e = hipSuccess;
|
||||
if(p) {
|
||||
size_t byteSize, width, height, depth, widthInBytes, srcPitch, dstPitch, ySize;
|
||||
hipChannelFormatDesc desc;
|
||||
void* srcPtr;void* dstPtr;
|
||||
size_t dstByteSize, srcByteSize, copyWidth, copyHeight, copyDepth, widthInBytes, srcPitch, dstPitch, srcYsize, dstYsize;
|
||||
size_t srcXoffset, srcYoffset, srcZoffset, dstXoffset, dstYoffset, dstZoffset;
|
||||
size_t srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth;
|
||||
|
||||
void* srcPtr, *dstPtr;
|
||||
bool copyWidthUpdate= false;
|
||||
copyDepth = p->extent.depth;
|
||||
copyHeight = p->extent.height;
|
||||
copyWidth = p->extent.width; // in bytes ?
|
||||
dstXoffset = p->dstPos.x;
|
||||
dstYoffset = p->dstPos.y;
|
||||
dstZoffset = p->dstPos.z;
|
||||
srcXoffset = p->srcPos.x;
|
||||
srcYoffset = p->srcPos.y;
|
||||
srcZoffset = p->srcPos.z;
|
||||
if (p->dstArray != nullptr) {
|
||||
if (p->dstArray->isDrv == false) {
|
||||
switch (p->dstArray->desc.f) {
|
||||
case hipChannelFormatKindSigned:
|
||||
byteSize = sizeof(int);
|
||||
break;
|
||||
case hipChannelFormatKindUnsigned:
|
||||
byteSize = sizeof(unsigned int);
|
||||
break;
|
||||
case hipChannelFormatKindFloat:
|
||||
byteSize = sizeof(float);
|
||||
break;
|
||||
case hipChannelFormatKindNone:
|
||||
byteSize = sizeof(size_t);
|
||||
break;
|
||||
default:
|
||||
byteSize = 0;
|
||||
break;
|
||||
}
|
||||
depth = p->extent.depth;
|
||||
height = p->extent.height;
|
||||
width = p->extent.width;
|
||||
widthInBytes = p->extent.width * byteSize;
|
||||
srcPitch = p->srcPtr.pitch;
|
||||
srcPtr = p->srcPtr.ptr;
|
||||
ySize = p->srcPtr.ysize;
|
||||
desc = p->dstArray->desc;
|
||||
dstPtr = p->dstArray->data;
|
||||
hsa_ext_image_data_info_t imageInfo;
|
||||
if(hipTextureType2DLayered == p->dstArray->textureType)
|
||||
GetImageInfo(HSA_EXT_IMAGE_GEOMETRY_2DA, width, height, 0, desc, imageInfo, depth);
|
||||
else
|
||||
GetImageInfo(HSA_EXT_IMAGE_GEOMETRY_3D, width, height, depth, desc, imageInfo);
|
||||
dstPitch = imageInfo.size/(height == 0 ? 1 : height)/(depth == 0 ? 1 : depth);
|
||||
} else {
|
||||
depth = p->Depth;
|
||||
height = p->Height;
|
||||
widthInBytes = p->WidthInBytes;
|
||||
width = p->dstArray->width;
|
||||
hsa_ext_image_channel_order_t channelOrder;
|
||||
switch(p->dstArray->NumChannels) {
|
||||
case 2:
|
||||
channelOrder = HSA_EXT_IMAGE_CHANNEL_ORDER_RG;
|
||||
break;
|
||||
case 3:
|
||||
channelOrder = HSA_EXT_IMAGE_CHANNEL_ORDER_RGB;
|
||||
break;
|
||||
case 4:
|
||||
channelOrder = HSA_EXT_IMAGE_CHANNEL_ORDER_RGBA;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
channelOrder = HSA_EXT_IMAGE_CHANNEL_ORDER_R;
|
||||
break;
|
||||
}
|
||||
hsa_ext_image_channel_type_t channelType;
|
||||
e = ihipArrayToImageFormat(p->dstArray->Format,channelType);
|
||||
srcPitch = p->srcPitch;
|
||||
srcPtr = (void*)p->srcHost;
|
||||
ySize = p->srcHeight;
|
||||
dstPtr = p->dstArray->data;
|
||||
hsa_ext_image_data_info_t imageInfo;
|
||||
if(hipTextureType2DLayered == p->dstArray->textureType)
|
||||
GetImageInfo(HSA_EXT_IMAGE_GEOMETRY_2DA, width, height, 0, channelOrder, channelType, imageInfo, depth);
|
||||
else
|
||||
GetImageInfo(HSA_EXT_IMAGE_GEOMETRY_3D, width, height, depth, channelOrder, channelType, imageInfo);
|
||||
dstPitch = imageInfo.size/(height == 0 ? 1 : height)/(depth == 0 ? 1 : depth);
|
||||
if ((p->dstArray->isDrv == true) ||( p->dstPtr.ptr!= nullptr)){
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
// Array destination
|
||||
dstByteSize = getByteSizeFromFormat(p->dstArray->desc);
|
||||
hipChannelFormatDesc desc;
|
||||
desc = p->dstArray->desc;
|
||||
dstPtr = p->dstArray->data;
|
||||
dstWidth = p->dstArray->width;
|
||||
dstHeight = p->dstArray->height;
|
||||
dstDepth = p->dstArray->depth;
|
||||
dstPitch = dstByteSize * alignUp(dstWidth, IMAGE_PITCH_ALIGNMENT);
|
||||
if(!copyWidthUpdate) {
|
||||
copyWidth = copyWidth * dstByteSize;
|
||||
copyWidthUpdate = true;
|
||||
}
|
||||
} else {
|
||||
// Non array destination
|
||||
depth = p->extent.depth;
|
||||
height = p->extent.height;
|
||||
widthInBytes = p->extent.width;
|
||||
srcPitch = p->srcPtr.pitch;
|
||||
srcPtr = p->srcPtr.ptr;
|
||||
//Non Array destination
|
||||
dstPtr = p->dstPtr.ptr;
|
||||
ySize = p->srcPtr.ysize;
|
||||
dstWidth = p->dstPtr.xsize;
|
||||
dstHeight = p->dstPtr.ysize;
|
||||
dstPitch = p->dstPtr.pitch;
|
||||
}
|
||||
|
||||
if (p->srcArray != nullptr) {
|
||||
if ((p->srcArray->isDrv == true) ||( p->srcPtr.ptr!= nullptr)){
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
// Array source
|
||||
srcByteSize = getByteSizeFromFormat(p->srcArray->desc);
|
||||
hipChannelFormatDesc desc;
|
||||
desc = p->srcArray->desc;
|
||||
srcPtr = p->srcArray->data;
|
||||
srcWidth = p->srcArray->width;
|
||||
srcHeight = p->srcArray->height;
|
||||
srcDepth = p->srcArray->depth;
|
||||
srcPitch = srcByteSize * alignUp(srcWidth, IMAGE_PITCH_ALIGNMENT);
|
||||
if(!copyWidthUpdate) {
|
||||
copyWidth = copyWidth * srcByteSize;
|
||||
copyWidthUpdate = true;
|
||||
}
|
||||
} else {
|
||||
//Non Array source
|
||||
srcPtr = p->srcPtr.ptr;
|
||||
srcWidth = p->srcPtr.xsize;
|
||||
srcHeight = p->srcPtr.ysize;
|
||||
srcPitch = p->srcPtr.pitch;
|
||||
}
|
||||
|
||||
stream = ihipSyncAndResolveStream(stream);
|
||||
try {
|
||||
if((widthInBytes == dstPitch) && (widthInBytes == srcPitch)) {
|
||||
if((copyWidth == dstPitch) && (copyWidth == srcPitch)&& (copyHeight == dstHeight) &&(copyHeight == srcHeight)) {
|
||||
if(isAsync)
|
||||
stream->locked_copyAsync((void*)dstPtr, (void*)srcPtr, widthInBytes*height*depth, p->kind);
|
||||
stream->locked_copyAsync((void*)dstPtr, (void*)srcPtr, copyWidth*copyHeight*copyDepth, p->kind);
|
||||
else
|
||||
stream->locked_copySync((void*)dstPtr, (void*)srcPtr, widthInBytes*height*depth, p->kind, false);
|
||||
stream->locked_copySync((void*)dstPtr, (void*)srcPtr, copyWidth*copyHeight*copyDepth, p->kind, false);
|
||||
} else {
|
||||
for (int i = 0; i < depth; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
// TODO: p->srcPos or p->dstPos are not 0.
|
||||
for (int i = 0; i < copyDepth; i++) {
|
||||
for (int j = 0; j < copyHeight; j++) {
|
||||
unsigned char* src =
|
||||
(unsigned char*)srcPtr + i * ySize * srcPitch + j * srcPitch;
|
||||
(unsigned char*)srcPtr + (i + srcZoffset) * srcHeight * srcPitch + (j + srcYoffset) * srcPitch + srcXoffset;
|
||||
unsigned char* dst =
|
||||
(unsigned char*)dstPtr + i * height * dstPitch + j * dstPitch;
|
||||
(unsigned char*)dstPtr + (i + dstZoffset) * dstHeight * dstPitch + (j + dstYoffset) * dstPitch + dstXoffset;
|
||||
if(isAsync)
|
||||
stream->locked_copyAsync(dst, src, widthInBytes, p->kind);
|
||||
stream->locked_copyAsync(dst, src, copyWidth, p->kind);
|
||||
else
|
||||
stream->locked_copySync(dst, src, widthInBytes, p->kind);
|
||||
stream->locked_copySync(dst, src, copyWidth, p->kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+94
-36
@@ -134,10 +134,10 @@ extern hipError_t ihipGetDeviceProperties(hipDeviceProp_t* props, int device);
|
||||
return ihipLogStatus(hipStatus); \
|
||||
}
|
||||
|
||||
hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t gridSizeX,
|
||||
uint32_t gridSizeY, uint32_t gridSizeZ,
|
||||
uint32_t blockSizeX, uint32_t blockSizeY,
|
||||
uint32_t blockSizeZ, size_t sharedMemBytes,
|
||||
hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t globalWorkSizeX,
|
||||
uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ,
|
||||
uint32_t localWorkSizeX, uint32_t localWorkSizeY,
|
||||
uint32_t localWorkSizeZ, size_t sharedMemBytes,
|
||||
hipStream_t hStream, void** kernelParams, void** extra,
|
||||
hipEvent_t startEvent, hipEvent_t stopEvent, uint32_t flags, bool isStreamLocked = 0,
|
||||
void** impCoopParams = 0) {
|
||||
@@ -146,14 +146,6 @@ hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t gridSi
|
||||
auto ctx = ihipGetTlsDefaultCtx();
|
||||
hipError_t ret = hipSuccess;
|
||||
|
||||
size_t globalWorkSizeX = (size_t)gridSizeX * (size_t)blockSizeX;
|
||||
size_t globalWorkSizeY = (size_t)gridSizeY * (size_t)blockSizeY;
|
||||
size_t globalWorkSizeZ = (size_t)gridSizeZ * (size_t)blockSizeZ;
|
||||
if(globalWorkSizeX > UINT32_MAX || globalWorkSizeY > UINT32_MAX || globalWorkSizeZ > UINT32_MAX)
|
||||
{
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
if (ctx == nullptr) {
|
||||
ret = hipErrorInvalidDevice;
|
||||
|
||||
@@ -211,8 +203,8 @@ hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t gridSi
|
||||
lp.dynamic_group_mem_bytes =
|
||||
sharedMemBytes; // TODO - this should be part of preLaunchKernel.
|
||||
hStream = ihipPreLaunchKernel(
|
||||
hStream, dim3(globalWorkSizeX/blockSizeX, globalWorkSizeY/blockSizeY, globalWorkSizeZ/blockSizeZ),
|
||||
dim3(blockSizeX, blockSizeY, blockSizeZ), &lp, f->_name.c_str(), isStreamLocked);
|
||||
hStream, dim3(globalWorkSizeX/localWorkSizeX, globalWorkSizeY/localWorkSizeY, globalWorkSizeZ/localWorkSizeZ),
|
||||
dim3(localWorkSizeX, localWorkSizeY, localWorkSizeZ), &lp, f->_name.c_str(), isStreamLocked);
|
||||
|
||||
hsa_kernel_dispatch_packet_t aql;
|
||||
|
||||
@@ -221,9 +213,9 @@ hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t gridSi
|
||||
// aql.completion_signal._handle = 0;
|
||||
// aql.kernarg_address = 0;
|
||||
|
||||
aql.workgroup_size_x = blockSizeX;
|
||||
aql.workgroup_size_y = blockSizeY;
|
||||
aql.workgroup_size_z = blockSizeZ;
|
||||
aql.workgroup_size_x = localWorkSizeX;
|
||||
aql.workgroup_size_y = localWorkSizeY;
|
||||
aql.workgroup_size_z = localWorkSizeZ;
|
||||
aql.grid_size_x = globalWorkSizeX;
|
||||
aql.grid_size_y = globalWorkSizeY;
|
||||
aql.grid_size_z = globalWorkSizeZ;
|
||||
@@ -283,8 +275,17 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, uint32_t gridDimX, uint32_t gr
|
||||
void** kernelParams, void** extra) {
|
||||
HIP_INIT_API(hipModuleLaunchKernel, f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ, sharedMemBytes,
|
||||
hStream, kernelParams, extra);
|
||||
|
||||
size_t globalWorkSizeX = (size_t)gridDimX * (size_t)blockDimX;
|
||||
size_t globalWorkSizeY = (size_t)gridDimY * (size_t)blockDimY;
|
||||
size_t globalWorkSizeZ = (size_t)gridDimZ * (size_t)blockDimZ;
|
||||
if(globalWorkSizeX > UINT32_MAX || globalWorkSizeY > UINT32_MAX || globalWorkSizeZ > UINT32_MAX)
|
||||
{
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
return ihipLogStatus(ihipModuleLaunchKernel(tls,
|
||||
f, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY,
|
||||
f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, blockDimX, blockDimY,
|
||||
blockDimZ, sharedMemBytes, hStream, kernelParams, extra, nullptr, nullptr, 0));
|
||||
}
|
||||
|
||||
@@ -297,11 +298,8 @@ hipError_t hipExtModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
|
||||
HIP_INIT_API(hipExtModuleLaunchKernel, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX,
|
||||
localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra);
|
||||
|
||||
if(localWorkSizeX == 0 || localWorkSizeY == 0 || localWorkSizeZ == 0)
|
||||
return hipErrorInvalidValue;
|
||||
|
||||
return ihipLogStatus(ihipModuleLaunchKernel(tls,
|
||||
f, globalWorkSizeX/localWorkSizeX, globalWorkSizeY/localWorkSizeY, globalWorkSizeZ/localWorkSizeZ, localWorkSizeX, localWorkSizeY,
|
||||
f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY,
|
||||
localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent, flags));
|
||||
}
|
||||
|
||||
@@ -314,11 +312,8 @@ hipError_t hipHccModuleLaunchKernel(hipFunction_t f, uint32_t globalWorkSizeX,
|
||||
HIP_INIT_API(hipHccModuleLaunchKernel, f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX,
|
||||
localWorkSizeY, localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra);
|
||||
|
||||
if(localWorkSizeX == 0 || localWorkSizeY == 0 || localWorkSizeZ == 0)
|
||||
return hipErrorInvalidValue;
|
||||
|
||||
return ihipLogStatus(ihipModuleLaunchKernel(tls,
|
||||
f, globalWorkSizeX/localWorkSizeX, globalWorkSizeY/localWorkSizeY, globalWorkSizeZ/localWorkSizeZ, localWorkSizeX, localWorkSizeY,
|
||||
f, globalWorkSizeX, globalWorkSizeY, globalWorkSizeZ, localWorkSizeX, localWorkSizeY,
|
||||
localWorkSizeZ, sharedMemBytes, hStream, kernelParams, extra, startEvent, stopEvent, 0));
|
||||
}
|
||||
|
||||
@@ -349,6 +344,8 @@ hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList
|
||||
free(kds);
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
if (!kds[i]->_kernarg_layout.empty()) continue;
|
||||
|
||||
hip_impl::kernargs_size_align kargs = ps.get_kernargs_size_align(
|
||||
reinterpret_cast<std::uintptr_t>(lp.func));
|
||||
kds[i]->_kernarg_layout = *reinterpret_cast<const std::vector<std::pair<std::size_t, std::size_t>>*>(
|
||||
@@ -364,14 +361,26 @@ hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList
|
||||
}
|
||||
|
||||
GET_TLS();
|
||||
|
||||
size_t globalWorkSizeX = 0, globalWorkSizeY = 0, globalWorkSizeZ = 0;
|
||||
|
||||
// launch kernels for each device
|
||||
for (int i = 0; i < numDevices; ++i) {
|
||||
const hipLaunchParams& lp = launchParamsList[i];
|
||||
|
||||
globalWorkSizeX = (size_t)lp.gridDim.x * (size_t)lp.blockDim.x;
|
||||
globalWorkSizeY = (size_t)lp.gridDim.y * (size_t)lp.blockDim.y;
|
||||
globalWorkSizeZ = (size_t)lp.gridDim.z * (size_t)lp.blockDim.z;
|
||||
|
||||
if(globalWorkSizeX > UINT32_MAX || globalWorkSizeY > UINT32_MAX || globalWorkSizeZ > UINT32_MAX)
|
||||
{
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
result = ihipModuleLaunchKernel(tls, kds[i],
|
||||
lp.gridDim.x,
|
||||
lp.gridDim.y,
|
||||
lp.gridDim.z,
|
||||
lp.gridDim.x * lp.blockDim.x,
|
||||
lp.gridDim.y * lp.blockDim.y,
|
||||
lp.gridDim.z * lp.blockDim.z,
|
||||
lp.blockDim.x, lp.blockDim.y,
|
||||
lp.blockDim.z, lp.sharedMem,
|
||||
lp.stream, lp.args, nullptr, nullptr, nullptr, 0,
|
||||
@@ -392,6 +401,14 @@ hipError_t ihipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList
|
||||
return result;
|
||||
}
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
hipError_t hipExtLaunchMultiKernelMultiDevice(hipLaunchParams* launchParamsList,
|
||||
int numDevices, unsigned int flags) {
|
||||
HIP_INIT_API(hipExtLaunchMultiKernelMultiDevice, launchParamsList, numDevices, flags);
|
||||
auto& ps = hip_impl::get_program_state();
|
||||
return ihipExtLaunchMultiKernelMultiDevice(launchParamsList, numDevices, flags, ps);
|
||||
}
|
||||
|
||||
namespace {
|
||||
// kernel for initializing GWS
|
||||
// nwm1 is the total number of work groups minus 1
|
||||
@@ -416,6 +433,14 @@ hipError_t ihipLaunchCooperativeKernel(const void* f, dim3 gridDim,
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
size_t globalWorkSizeX = (size_t)gridDim.x * (size_t)blockDimX.x;
|
||||
size_t globalWorkSizeY = (size_t)gridDim.y * (size_t)blockDimX.y;
|
||||
size_t globalWorkSizeZ = (size_t)gridDim.z * (size_t)blockDimX.z;
|
||||
if(globalWorkSizeX > UINT32_MAX || globalWorkSizeY > UINT32_MAX || globalWorkSizeZ > UINT32_MAX)
|
||||
{
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
// Prepare the kernel descriptor for initializing the GWS
|
||||
hipFunction_t gwsKD = ps.kernel_descriptor(
|
||||
reinterpret_cast<std::uintptr_t>(&init_gws),
|
||||
@@ -475,9 +500,9 @@ hipError_t ihipLaunchCooperativeKernel(const void* f, dim3 gridDim,
|
||||
|
||||
// launch the main kernel
|
||||
result = ihipModuleLaunchKernel(tls, kd,
|
||||
gridDim.x,
|
||||
gridDim.y,
|
||||
gridDim.z,
|
||||
gridDim.x * blockDimX.x,
|
||||
gridDim.y * blockDimX.y,
|
||||
gridDim.z * blockDimX.z,
|
||||
blockDimX.x, blockDimX.y, blockDimX.z,
|
||||
sharedMemBytes, stream, kernelParams, nullptr, nullptr,
|
||||
nullptr, 0, true, impCoopParams);
|
||||
@@ -612,6 +637,8 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL
|
||||
|
||||
void* impCoopParams[1];
|
||||
ulong prev_sum = 0;
|
||||
|
||||
size_t globalWorkSizeX = 0, globalWorkSizeY = 0, globalWorkSizeZ = 0;
|
||||
// launch the main kernels for each device
|
||||
for (int i = 0; i < numDevices; ++i) {
|
||||
const hipLaunchParams& lp = launchParamsList[i];
|
||||
@@ -628,10 +655,18 @@ hipError_t ihipLaunchCooperativeKernelMultiDevice(hipLaunchParams* launchParamsL
|
||||
|
||||
impCoopParams[0] = &mg_info_ptr[i];
|
||||
|
||||
globalWorkSizeX = (size_t)lp.gridDim.x * (size_t)lp.blockDim.x;
|
||||
globalWorkSizeY = (size_t)lp.gridDim.y * (size_t)lp.blockDim.y;
|
||||
globalWorkSizeZ = (size_t)lp.gridDim.z * (size_t)lp.blockDim.z;
|
||||
if(globalWorkSizeX > UINT32_MAX || globalWorkSizeY > UINT32_MAX || globalWorkSizeZ > UINT32_MAX)
|
||||
{
|
||||
return hipErrorInvalidConfiguration;
|
||||
}
|
||||
|
||||
result = ihipModuleLaunchKernel(tls, kds[i],
|
||||
lp.gridDim.x,
|
||||
lp.gridDim.y,
|
||||
lp.gridDim.z,
|
||||
lp.gridDim.x * lp.blockDim.x,
|
||||
lp.gridDim.y * lp.blockDim.y,
|
||||
lp.gridDim.z * lp.blockDim.z,
|
||||
lp.blockDim.x, lp.blockDim.y,
|
||||
lp.blockDim.z, lp.sharedMem,
|
||||
lp.stream, lp.args, nullptr, nullptr, nullptr, 0,
|
||||
@@ -846,7 +881,12 @@ namespace hip_impl {
|
||||
|
||||
hipError_t agent_globals::read_agent_global_from_process(hipDeviceptr_t* dptr, size_t* bytes,
|
||||
const char* name) {
|
||||
return impl->read_agent_global_from_process(dptr, bytes, name);
|
||||
hipError_t result = impl->read_agent_global_from_process(dptr, bytes, name);
|
||||
if(result != hipSuccess) {
|
||||
// For Clang Compiler + Hcc Rt
|
||||
result = ihipGetGlobalVar(dptr, bytes, name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // Namespace hip_impl.
|
||||
@@ -1461,6 +1501,15 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
tls, numBlocks, f, blockSize, dynSharedMemPerBlk));
|
||||
}
|
||||
|
||||
hipError_t hipDrvOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk)
|
||||
{
|
||||
HIP_INIT_API(hipDrvOccupancyMaxActiveBlocksPerMultiprocessor, numBlocks, f, blockSize, dynSharedMemPerBlk);
|
||||
|
||||
return ihipLogStatus(ihipOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
tls, (uint32_t*) numBlocks, f, blockSize, dynSharedMemPerBlk));
|
||||
}
|
||||
|
||||
hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
uint32_t* numBlocks, hipFunction_t f, uint32_t blockSize, size_t dynSharedMemPerBlk,
|
||||
unsigned int flags)
|
||||
@@ -1471,6 +1520,15 @@ hipError_t hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
tls, numBlocks, f, blockSize, dynSharedMemPerBlk));
|
||||
}
|
||||
|
||||
hipError_t hipDrvOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(
|
||||
int* numBlocks, hipFunction_t f, int blockSize, size_t dynSharedMemPerBlk,
|
||||
unsigned int flags)
|
||||
{
|
||||
HIP_INIT_API(hipDrvOccupancyMaxActiveBlocksPerMultiprocessorWithFlags, numBlocks, f, blockSize, dynSharedMemPerBlk, flags);
|
||||
return ihipLogStatus(ihipOccupancyMaxActiveBlocksPerMultiprocessor(
|
||||
tls, (uint32_t*) numBlocks, f, blockSize, dynSharedMemPerBlk));
|
||||
}
|
||||
|
||||
hipError_t hipLaunchKernel(
|
||||
const void* func_addr, dim3 numBlocks, dim3 dimBlocks, void** args,
|
||||
size_t sharedMemBytes, hipStream_t stream)
|
||||
|
||||
+17
-10
@@ -128,17 +128,24 @@ hipError_t ihipEnablePeerAccess(TlsData* tls, hipCtx_t peerCtx, unsigned int fla
|
||||
if (thisCtx == peerCtx) {
|
||||
err = hipErrorInvalidDevice; // Can't enable peer access to self.
|
||||
} else if ((thisCtx != NULL) && (peerCtx != NULL)) {
|
||||
LockedAccessor_CtxCrit_t peerCrit(peerCtx->criticalData());
|
||||
// Add thisCtx to peerCtx's access list so that new allocations on peer will be made
|
||||
// visible to this device:
|
||||
bool isNewPeer = peerCrit->addPeerWatcher(peerCtx, thisCtx);
|
||||
if (isNewPeer) {
|
||||
tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n",
|
||||
thisCtx->toString().c_str(), peerCtx->toString().c_str());
|
||||
am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(),
|
||||
peerCrit->peerAgents());
|
||||
|
||||
int canAccess = 0;
|
||||
if ((hipSuccess != ihipDeviceCanAccessPeer(&canAccess,thisCtx,peerCtx)) || (canAccess == 0)){
|
||||
tprintf(DB_MEM, "device=%s can't access peer=%s\n",thisCtx->toString().c_str(), peerCtx->toString().c_str());
|
||||
err = hipErrorInvalidDevice;
|
||||
} else {
|
||||
err = hipErrorPeerAccessAlreadyEnabled;
|
||||
LockedAccessor_CtxCrit_t peerCrit(peerCtx->criticalData());
|
||||
// Add thisCtx to peerCtx's access list so that new allocations on peer will be made
|
||||
// visible to this device:
|
||||
bool isNewPeer = peerCrit->addPeerWatcher(peerCtx, thisCtx);
|
||||
if (isNewPeer) {
|
||||
tprintf(DB_MEM, "device=%s can now see all memory allocated on peer=%s\n",
|
||||
thisCtx->toString().c_str(), peerCtx->toString().c_str());
|
||||
am_memtracker_update_peers(peerCtx->getDevice()->_acc, peerCrit->peerCnt(),
|
||||
peerCrit->peerAgents());
|
||||
} else {
|
||||
err = hipErrorPeerAccessAlreadyEnabled;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = hipErrorInvalidDevice;
|
||||
|
||||
+40
-28
@@ -50,7 +50,7 @@ THE SOFTWARE.
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
const char* hiprtcGetErrorString(hiprtcResult x)
|
||||
extern "C" const char* hiprtcGetErrorString(hiprtcResult x)
|
||||
{
|
||||
switch (x) {
|
||||
case HIPRTC_SUCCESS:
|
||||
@@ -95,6 +95,21 @@ inline bool fileExists (const std::string& name) {
|
||||
}
|
||||
} // namespace hip_impl
|
||||
|
||||
namespace
|
||||
{
|
||||
char* demangle(const char* x)
|
||||
{
|
||||
if (!x) return nullptr;
|
||||
|
||||
int s{};
|
||||
char* tmp = abi::__cxa_demangle(x, nullptr, nullptr, &s);
|
||||
|
||||
if (s != 0) return nullptr;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
} // Unnamed namespace.
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Symbol {
|
||||
@@ -158,7 +173,7 @@ struct _hiprtcProgram {
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
char* demangled = hip_impl::demangle(name.c_str());
|
||||
char* demangled = demangle(name.c_str());
|
||||
name.assign(demangled == nullptr ? "" : demangled);
|
||||
free(demangled);
|
||||
|
||||
@@ -235,7 +250,7 @@ struct _hiprtcProgram {
|
||||
|
||||
const auto it{find_if(reader.sections.begin(), reader.sections.end(),
|
||||
[](const section* x) {
|
||||
return x->get_name() == ".kernel";
|
||||
return (x->get_name() == ".hip_fatbin") || (x->get_name() == ".kernel");
|
||||
})};
|
||||
|
||||
if (it == reader.sections.end()) return false;
|
||||
@@ -352,7 +367,7 @@ namespace
|
||||
}
|
||||
} // Unnamed namespace.
|
||||
|
||||
hiprtcResult hiprtcAddNameExpression(hiprtcProgram p, const char* n)
|
||||
extern "C" hiprtcResult hiprtcAddNameExpression(hiprtcProgram p, const char* n)
|
||||
{
|
||||
if (!n) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
if (!isValidProgram(p)) return HIPRTC_ERROR_INVALID_PROGRAM;
|
||||
@@ -413,21 +428,6 @@ namespace
|
||||
};
|
||||
} // Unnamed namespace.
|
||||
|
||||
namespace hip_impl
|
||||
{
|
||||
char* demangle(const char* x)
|
||||
{
|
||||
if (!x) return nullptr;
|
||||
|
||||
int s{};
|
||||
char* tmp = abi::__cxa_demangle(x, nullptr, nullptr, &s);
|
||||
|
||||
if (s != 0) return nullptr;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
} // Namespace hip_impl.
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string& defaultTarget()
|
||||
@@ -492,7 +492,7 @@ namespace
|
||||
}
|
||||
} // Unnamed namespace.
|
||||
|
||||
hiprtcResult hiprtcCompileProgram(hiprtcProgram p, int n, const char** o)
|
||||
extern "C" hiprtcResult hiprtcCompileProgram(hiprtcProgram p, int n, const char** o)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
@@ -513,7 +513,7 @@ hiprtcResult hiprtcCompileProgram(hiprtcProgram p, int n, const char** o)
|
||||
|
||||
const auto src{p->writeTemporaryFiles(tmp.path())};
|
||||
|
||||
vector<string> args{hipcc, "-shared"};
|
||||
vector<string> args{hipcc, "-fPIC -shared"};
|
||||
if (n) args.insert(args.cend(), o, o + n);
|
||||
|
||||
handleTarget(args);
|
||||
@@ -530,7 +530,7 @@ hiprtcResult hiprtcCompileProgram(hiprtcProgram p, int n, const char** o)
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcCreateProgram(hiprtcProgram* p, const char* src,
|
||||
extern "C" hiprtcResult hiprtcCreateProgram(hiprtcProgram* p, const char* src,
|
||||
const char* name, int n, const char** hdrs,
|
||||
const char** incs)
|
||||
{
|
||||
@@ -548,14 +548,14 @@ hiprtcResult hiprtcCreateProgram(hiprtcProgram* p, const char* src,
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcDestroyProgram(hiprtcProgram* p)
|
||||
extern "C" hiprtcResult hiprtcDestroyProgram(hiprtcProgram* p)
|
||||
{
|
||||
if (!p) return HIPRTC_SUCCESS;
|
||||
|
||||
return _hiprtcProgram::destroy(*p);
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcGetLoweredName(hiprtcProgram p, const char* n,
|
||||
extern "C" hiprtcResult hiprtcGetLoweredName(hiprtcProgram p, const char* n,
|
||||
const char** ln)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -576,7 +576,7 @@ hiprtcResult hiprtcGetLoweredName(hiprtcProgram p, const char* n,
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcGetProgramLog(hiprtcProgram p, char* l)
|
||||
extern "C" hiprtcResult hiprtcGetProgramLog(hiprtcProgram p, char* l)
|
||||
{
|
||||
if (!l) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
if (!isValidProgram(p)) return HIPRTC_ERROR_INVALID_PROGRAM;
|
||||
@@ -588,7 +588,7 @@ hiprtcResult hiprtcGetProgramLog(hiprtcProgram p, char* l)
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram p, std::size_t* sz)
|
||||
extern "C" hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram p, std::size_t* sz)
|
||||
{
|
||||
if (!sz) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
if (!isValidProgram(p)) return HIPRTC_ERROR_INVALID_PROGRAM;
|
||||
@@ -599,7 +599,7 @@ hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram p, std::size_t* sz)
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcGetCode(hiprtcProgram p, char* c)
|
||||
extern "C" hiprtcResult hiprtcGetCode(hiprtcProgram p, char* c)
|
||||
{
|
||||
if (!c) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
if (!isValidProgram(p)) return HIPRTC_ERROR_INVALID_PROGRAM;
|
||||
@@ -610,7 +610,7 @@ hiprtcResult hiprtcGetCode(hiprtcProgram p, char* c)
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
hiprtcResult hiprtcGetCodeSize(hiprtcProgram p, std::size_t* sz)
|
||||
extern "C" hiprtcResult hiprtcGetCodeSize(hiprtcProgram p, std::size_t* sz)
|
||||
{
|
||||
if (!sz) return HIPRTC_ERROR_INVALID_INPUT;
|
||||
if (!isValidProgram(p)) return HIPRTC_ERROR_INVALID_PROGRAM;
|
||||
@@ -620,3 +620,15 @@ hiprtcResult hiprtcGetCodeSize(hiprtcProgram p, std::size_t* sz)
|
||||
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
extern "C" hiprtcResult hiprtcVersion(int* major, int* minor)
|
||||
{
|
||||
if (major == nullptr || minor == nullptr) {
|
||||
return HIPRTC_ERROR_INVALID_INPUT;
|
||||
}
|
||||
|
||||
*major = 9;
|
||||
*minor = 0;
|
||||
|
||||
return HIPRTC_SUCCESS;
|
||||
}
|
||||
|
||||
+20
-10
@@ -19,6 +19,8 @@
|
||||
#include <hsa/hsa_ven_amd_loader.h>
|
||||
#include <amd_comgr.h>
|
||||
#include "hc.hpp"
|
||||
#include "hip_hcc_internal.h"
|
||||
#include "trace_helper.h"
|
||||
|
||||
#include <link.h>
|
||||
|
||||
@@ -26,6 +28,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
@@ -202,7 +205,7 @@ public:
|
||||
std::function<void(hsa_code_object_reader_t*)>>;
|
||||
std::pair<
|
||||
std::mutex,
|
||||
std::vector<std::pair<std::string, RAII_code_reader>>> code_readers;
|
||||
std::deque<std::pair<std::string, RAII_code_reader>>> code_readers;
|
||||
|
||||
program_state_impl() {
|
||||
// Create placeholder for each agent for the per-agent members.
|
||||
@@ -244,7 +247,8 @@ public:
|
||||
if (!valid(tmp)) break;
|
||||
|
||||
for (auto&& bundle : bundles(tmp)) {
|
||||
impl.code_object_blobs.second[elf][triple_to_hsa_isa(bundle.triple)].push_back(bundle.blob);
|
||||
if(bundle.blob.size())
|
||||
impl.code_object_blobs.second[elf][triple_to_hsa_isa(bundle.triple)].push_back(bundle.blob);
|
||||
}
|
||||
|
||||
blob_it += tmp.bundled_code_size;
|
||||
@@ -418,13 +422,17 @@ public:
|
||||
decltype(code_readers.second)::iterator it;
|
||||
{
|
||||
std::lock_guard<std::mutex> lck{code_readers.first};
|
||||
it = code_readers.second.emplace(code_readers.second.end(),
|
||||
move(file), move(tmp));
|
||||
code_readers.second.emplace_back(move(file), move(tmp));
|
||||
it = std::prev(code_readers.second.end());
|
||||
}
|
||||
|
||||
auto check_hsa_error = [](hsa_status_t s) {
|
||||
if (s != HSA_STATUS_SUCCESS) {
|
||||
hip_throw(std::runtime_error{"error when loading code object"});
|
||||
const char* hsa_err_msg;
|
||||
hsa_status_string(s, &hsa_err_msg);
|
||||
hip_throw(std::runtime_error{
|
||||
std::string("error when loading code object: ") +
|
||||
hsa_err_msg});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -938,14 +946,16 @@ public:
|
||||
|
||||
auto it0 = get_functions(agent).find(function_address);
|
||||
|
||||
if (it0 == get_functions(agent).cend()) {
|
||||
hip_throw(std::runtime_error{
|
||||
if (it0 != get_functions(agent).cend()) return it0->second;
|
||||
|
||||
// For hip-clang compiler + Hcc RT
|
||||
hipFunction_t f = ihipGetDeviceFunction((const void*)function_address);
|
||||
if (f) return reinterpret_cast<Kernel_descriptor&>(*f);
|
||||
|
||||
hip_throw(std::runtime_error{
|
||||
"No device code available for function: " +
|
||||
std::string(name(function_address)) +
|
||||
", for agent: " + name(agent)});
|
||||
}
|
||||
|
||||
return it0->second;
|
||||
}
|
||||
|
||||
const std::vector<std::pair<std::size_t, std::size_t>>&
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -std=c++11 --gpu-architecture=sm_60 EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS -std=c++11 --gpu-architecture=sm_60
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --Wno-deprecated-declarations EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --Wno-deprecated-declarations
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --Wno-deprecated-declarations EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --Wno-deprecated-declarations
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --gpu-architecture=sm_35 EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp NVCC_OPTIONS --gpu-architecture=sm_35
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: gpu.o %hc -I%hip-path/include -g -c %S/gpu.cpp -o %T/gpu.o EXCLUDE_HIP_PLATFORM nvcc vdi EXCLUDE_HIP_COMPILER clang
|
||||
* BUILD_CMD: launchkernel.o %hc -D__HIP_PLATFORM_HCC__ -g -I%hip-path/include -c %S/LaunchKernel.c -o %T/launchkernel.o EXCLUDE_HIP_PLATFORM nvcc vdi EXCLUDE_HIP_COMPILER clang
|
||||
* BUILD_CMD: LaunchKernel %hc %T/launchkernel.o %T/gpu.o -g -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/%t DEPENDS gpu.o launchkernel.o EXCLUDE_HIP_PLATFORM nvcc vdi EXCLUDE_HIP_COMPILER clang
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc vdi EXCLUDE_HIP_COMPILER clang
|
||||
* BUILD_CMD: gpu.o %hc -I%hip-path/include -g -c %S/gpu.cpp -o %T/gpu.o EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD_CMD: launchkernel.o %hc -D__HIP_PLATFORM_HCC__ -g -I%hip-path/include -c %S/LaunchKernel.c -o %T/launchkernel.o EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD_CMD: LaunchKernel %hc %T/launchkernel.o %T/gpu.o -g -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/%t DEPENDS gpu.o launchkernel.o EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_NVCC__ -I%hip-path/include -I/usr/local/cuda/include %S/%s -o %T/hipMalloc_nv -L/usr/local/cuda/lib64 -lcudart EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_HCC__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD_CMD: hipMalloc %cc -D__HIP_PLATFORM_HCC__ -I%hip-path/include %S/%s -Wl,--rpath=%hip-path/lib %hip-path/lib/libhip_hcc.so -o %T/hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* TEST: hipMalloc_nv EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* TEST: hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: hipMalloc_hcc EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -34,42 +34,52 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
|
||||
|
||||
using namespace std;
|
||||
|
||||
const string directed_dir = "directed_tests" + string(PATH_SEPERATOR_STR) + "hipEnvVar";
|
||||
const string dir = "." + string(PATH_SEPERATOR_STR) + "hipEnvVar";
|
||||
const string directed_dir = string(".") + PATH_SEPERATOR_STR + "directed_tests" + PATH_SEPERATOR_STR + "hipEnvVar";
|
||||
const string dir = string(".") + PATH_SEPERATOR_STR + "hipEnvVar";
|
||||
|
||||
int getDeviceNumber() {
|
||||
char buff[512];
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
FILE* in = popen((directed_dir + " -c").c_str(), "r");
|
||||
if(fgets(buff, 512, in) == NULL){
|
||||
pclose(in);
|
||||
//Check at same level
|
||||
in = popen((dir + " -c").c_str(), "r");
|
||||
int readHipEnvVar(string flags, char* buff){
|
||||
|
||||
std::cout << "\nFinding hipEnvVar in " << directed_dir << "...\n";
|
||||
FILE* directed_in = popen((directed_dir + flags).c_str(), "r");
|
||||
|
||||
if(fgets(buff, 512, directed_in) == NULL){
|
||||
std::cout << "Finding hipEnvVar in " << dir << "...\n";
|
||||
FILE* in = popen((dir + flags).c_str(), "r");
|
||||
if(fgets(buff, 512, in) == NULL){
|
||||
pclose(directed_in);
|
||||
pclose(in);
|
||||
return 1;
|
||||
}
|
||||
pclose(in);
|
||||
}
|
||||
std::cout << "hipEnvVar Found!\n";
|
||||
pclose(directed_in);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getDeviceNumber(bool print_err=true) {
|
||||
char buff[512];
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
|
||||
if (readHipEnvVar(string(" -c"), buff)){
|
||||
strncpy(buff, "1", 512);
|
||||
if (print_err){
|
||||
std::cerr << "The system cannot find hipEnvVar, using 1 as number of devices\n";
|
||||
}
|
||||
}
|
||||
if (print_err) {
|
||||
std::cout << buff;
|
||||
}
|
||||
cout << buff;
|
||||
pclose(in);
|
||||
return atoi(buff);
|
||||
}
|
||||
|
||||
// Query the current device ID remotely to hipEnvVar
|
||||
void getDevicePCIBusNumRemote(int deviceID, char* pciBusID) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
FILE* in = popen((directed_dir + " -d " + std::to_string(deviceID)).c_str(), "r");
|
||||
if(fgets(pciBusID, 100, in) == NULL){
|
||||
pclose(in);
|
||||
//Check at same level
|
||||
in = popen((dir + " -d").c_str(), "r");
|
||||
if(fgets(pciBusID, 100, in) == NULL){
|
||||
pclose(in);
|
||||
return;
|
||||
}
|
||||
if (readHipEnvVar((" -d " + std::to_string(deviceID)), pciBusID)){
|
||||
std::cerr << "The system cannot find hipEnvVar\n";
|
||||
}
|
||||
cout << pciBusID;
|
||||
pclose(in);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,15 +88,15 @@ void getDevicePCIBusNum(int deviceID, char* pciBusID) {
|
||||
hipDevice_t deviceT;
|
||||
hipDeviceGet(&deviceT, deviceID);
|
||||
|
||||
memset(pciBusID, 0, 100);
|
||||
hipDeviceGetPCIBusId(pciBusID, 100, deviceT);
|
||||
memset(pciBusID, 0, 512);
|
||||
hipDeviceGetPCIBusId(pciBusID, 512, deviceT);
|
||||
}
|
||||
|
||||
int main() {
|
||||
unsetenv(HIP_VISIBLE_DEVICES_STR);
|
||||
unsetenv(CUDA_VISIBLE_DEVICES_STR);
|
||||
std::vector<std::string> devPCINum;
|
||||
char pciBusID[100];
|
||||
char pciBusID[512];
|
||||
// collect the device pci bus ID for all devices
|
||||
int totalDeviceNum = getDeviceNumber();
|
||||
std::cout << "The total number of available devices is " << totalDeviceNum << std::endl
|
||||
@@ -116,27 +126,27 @@ int main() {
|
||||
// check when set an invalid device number
|
||||
setenv("HIP_VISIBLE_DEVICES", "1000,0,1", 1);
|
||||
setenv("CUDA_VISIBLE_DEVICES", "1000,0,1", 1);
|
||||
assert(getDeviceNumber() == 0);
|
||||
assert(getDeviceNumber(false) == 0);
|
||||
|
||||
if (totalDeviceNum > 2) {
|
||||
setenv("HIP_VISIBLE_DEVICES", "0,1,1000,2", 1);
|
||||
setenv("CUDA_VISIBLE_DEVICES", "0,1,1000,2", 1);
|
||||
assert(getDeviceNumber() == 2);
|
||||
assert(getDeviceNumber(false) == 2);
|
||||
|
||||
setenv("HIP_VISIBLE_DEVICES", "0,1,2", 1);
|
||||
setenv("CUDA_VISIBLE_DEVICES", "0,1,2", 1);
|
||||
assert(getDeviceNumber() == 3);
|
||||
assert(getDeviceNumber(false) == 3);
|
||||
// test if CUDA_VISIBLE_DEVICES will be accepted by the runtime
|
||||
unsetenv(HIP_VISIBLE_DEVICES_STR);
|
||||
unsetenv(CUDA_VISIBLE_DEVICES_STR);
|
||||
setenv("CUDA_VISIBLE_DEVICES", "0,1,2", 1);
|
||||
assert(getDeviceNumber() == 3);
|
||||
assert(getDeviceNumber(false) == 3);
|
||||
}
|
||||
|
||||
setenv("HIP_VISIBLE_DEVICES", "-100,0,1", 1);
|
||||
setenv("CUDA_VISIBLE_DEVICES", "-100,0,1", 1);
|
||||
assert(getDeviceNumber() == 0);
|
||||
assert(getDeviceNumber(false) == 0);
|
||||
|
||||
std::cout << "PASSED" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
// Test the HCC-specific API extensions for HIP:
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM all
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp LINK_OPTIONS hiprtc EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include <test_common.h>
|
||||
|
||||
#define HIPRTC_GET_TYPE_NAME
|
||||
#include <hip/hiprtc.h>
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
static constexpr auto gpu_program{
|
||||
R"(
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
namespace N1 { struct S1_t { int i; double d; }; }
|
||||
template<typename T>
|
||||
__global__ void f3(int *result) { *result = sizeof(T); }
|
||||
)"};
|
||||
|
||||
// note: this structure is also defined in GPU code string. Should ideally
|
||||
// be in a header file included by both GPU code string and by CPU code.
|
||||
namespace N1 { struct S1_t { int i; double d; }; };
|
||||
|
||||
template <typename T>
|
||||
std::string getKernelNameForType(void)
|
||||
{
|
||||
std::string type_name;
|
||||
hiprtcGetTypeName<T>(&type_name);
|
||||
return std::string{"f3<"} + type_name + '>';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
hiprtcProgram prog;
|
||||
hiprtcCreateProgram(&prog, gpu_program, "gpu_program.cu", 0, nullptr,
|
||||
nullptr);
|
||||
|
||||
vector<string> name_vec;
|
||||
vector<int> expected_result;
|
||||
|
||||
name_vec.push_back(getKernelNameForType<int>());
|
||||
expected_result.push_back(sizeof(int));
|
||||
name_vec.push_back(getKernelNameForType<double>());
|
||||
expected_result.push_back(sizeof(double));
|
||||
name_vec.push_back(getKernelNameForType<N1::S1_t>());
|
||||
expected_result.push_back(sizeof(N1::S1_t));
|
||||
|
||||
for (auto&& x : name_vec) hiprtcAddNameExpression(prog, x.c_str());
|
||||
|
||||
hipDeviceProp_t props;
|
||||
int device = 0;
|
||||
hipGetDeviceProperties(&props, device);
|
||||
std::string gfxName = "gfx" + std::to_string(props.gcnArch);
|
||||
std::string sarg = "--gpu-architecture=" + gfxName;
|
||||
const char* options[] = {
|
||||
sarg.c_str()
|
||||
};
|
||||
|
||||
hiprtcResult compileResult = hiprtcCompileProgram(prog, 1, options);
|
||||
|
||||
size_t logSize;
|
||||
hiprtcGetProgramLogSize(prog, &logSize);
|
||||
|
||||
if (logSize) {
|
||||
string log(logSize, '\0');
|
||||
hiprtcGetProgramLog(prog, &log[0]);
|
||||
|
||||
cout << log << '\n';
|
||||
}
|
||||
|
||||
if (compileResult != HIPRTC_SUCCESS) { failed("Compilation failed."); }
|
||||
|
||||
size_t codeSize;
|
||||
hiprtcGetCodeSize(prog, &codeSize);
|
||||
|
||||
vector<char> code(codeSize);
|
||||
hiprtcGetCode(prog, code.data());
|
||||
|
||||
hipModule_t module;
|
||||
hipModuleLoadDataEx(&module, code.data(), 0, nullptr, nullptr);
|
||||
|
||||
hipDeviceptr_t dResult;
|
||||
int hResult = 0;
|
||||
hipMalloc(&dResult, sizeof(hResult));
|
||||
hipMemcpyHtoD(dResult, &hResult, sizeof(hResult));
|
||||
|
||||
for (size_t i = 0; i < name_vec.size(); ++i) {
|
||||
const char *name;
|
||||
hiprtcGetLoweredName(prog, name_vec[i].c_str(), &name);
|
||||
|
||||
hipFunction_t kernel;
|
||||
hipModuleGetFunction(&kernel, module, name);
|
||||
|
||||
struct { hipDeviceptr_t a_; } args{dResult};
|
||||
|
||||
auto size = sizeof(args);
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
|
||||
hipModuleLaunchKernel(kernel,
|
||||
1, 1, 1,
|
||||
1, 1, 1,
|
||||
0, nullptr,
|
||||
nullptr, config);
|
||||
|
||||
hipMemcpyDtoH(&hResult, dResult, sizeof(hResult));
|
||||
|
||||
if (expected_result[i] != hResult) { failed("Validation failed."); }
|
||||
}
|
||||
|
||||
hipFree(dResult);
|
||||
hipModuleUnload(module);
|
||||
|
||||
hiprtcDestroyProgram(&prog);
|
||||
|
||||
passed();
|
||||
}
|
||||
@@ -143,7 +143,7 @@ int main()
|
||||
hipMemcpyDtoH(hOut.get(), dOut, bufferSize);
|
||||
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (a * hX[i] + hY[i] != hOut[i]) { failed("Validation failed."); }
|
||||
if (fabs(a * hX[i] + hY[i] - hOut[i]) > fabs(hOut[i])* 1e-6) { failed("Validation failed."); }
|
||||
}
|
||||
|
||||
hipFree(dX);
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM all
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM NVCC EXCLUDE_HIP_RUNTIME HCC EXCLUDE_HIP_COMPILER hcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM all
|
||||
* BUILD: %t %s EXCLUDE_HIP_PLATFORM NVCC EXCLUDE_HIP_RUNTIME HCC EXCLUDE_HIP_COMPILER hcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM hcc
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM nvcc
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,7 @@ THE SOFTWARE.
|
||||
// Test the Grid_Launch syntax.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
Copyright (c) 2015-present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "test_common.h"
|
||||
|
||||
#define WIDTH 4
|
||||
|
||||
#define NUM (WIDTH * WIDTH)
|
||||
|
||||
#define THREADS_PER_BLOCK_X 4
|
||||
#define THREADS_PER_BLOCK_Y 4
|
||||
#define THREADS_PER_BLOCK_Z 1
|
||||
|
||||
// Device (Kernel) function, it must be void
|
||||
template <typename T>
|
||||
__global__ void matrixTranspose(T* out, T* in, const int width) {
|
||||
int x = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x;
|
||||
T val = in[x];
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < width; j++) out[i * width + j] = __shfl(val, j * width + i);
|
||||
}
|
||||
}
|
||||
|
||||
// CPU implementation of matrix transpose
|
||||
template <typename T>
|
||||
void matrixTransposeCPUReference(T* output, T* input, const unsigned int width) {
|
||||
for (unsigned int j = 0; j < width; j++) {
|
||||
for (unsigned int i = 0; i < width; i++) {
|
||||
output[i * width + j] = input[j * width + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void runTest() {
|
||||
T* Matrix;
|
||||
T* TransposeMatrix;
|
||||
T* cpuTransposeMatrix;
|
||||
|
||||
T* gpuMatrix;
|
||||
T* gpuTransposeMatrix;
|
||||
|
||||
hipDeviceProp_t devProp;
|
||||
hipGetDeviceProperties(&devProp, 0);
|
||||
|
||||
int i;
|
||||
int errors;
|
||||
|
||||
Matrix = (T*)malloc(NUM * sizeof(T));
|
||||
TransposeMatrix = (T*)malloc(NUM * sizeof(T));
|
||||
cpuTransposeMatrix = (T*)malloc(NUM * sizeof(T));
|
||||
|
||||
// initialize the input data
|
||||
for (i = 0; i < NUM; i++) {
|
||||
Matrix[i] = (T)i * 10l;
|
||||
}
|
||||
|
||||
// allocate the memory on the device side
|
||||
hipMalloc((void**)&gpuMatrix, NUM * sizeof(T));
|
||||
hipMalloc((void**)&gpuTransposeMatrix, NUM * sizeof(T));
|
||||
|
||||
// Memory transfer from host to device
|
||||
hipMemcpy(gpuMatrix, Matrix, NUM * sizeof(T), hipMemcpyHostToDevice);
|
||||
|
||||
// Lauching kernel from host
|
||||
hipLaunchKernelGGL(matrixTranspose<T>, dim3(1), dim3(THREADS_PER_BLOCK_X * THREADS_PER_BLOCK_Y), 0, 0,
|
||||
gpuTransposeMatrix, gpuMatrix, WIDTH);
|
||||
|
||||
// Memory transfer from device to host
|
||||
hipMemcpy(TransposeMatrix, gpuTransposeMatrix, NUM * sizeof(T), hipMemcpyDeviceToHost);
|
||||
|
||||
// CPU MatrixTranspose computation
|
||||
matrixTransposeCPUReference(cpuTransposeMatrix, Matrix, WIDTH);
|
||||
|
||||
// verify the results
|
||||
errors = 0;
|
||||
double eps = 1.0E-6;
|
||||
for (i = 0; i < NUM; i++) {
|
||||
if (TransposeMatrix[i] != cpuTransposeMatrix[i]) {
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
// free the resources on device side
|
||||
hipFree(gpuMatrix);
|
||||
hipFree(gpuTransposeMatrix);
|
||||
|
||||
// free the resources on host side
|
||||
free(Matrix);
|
||||
free(TransposeMatrix);
|
||||
free(cpuTransposeMatrix);
|
||||
|
||||
if (errors != 0) {
|
||||
failed("Mismatch present");
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
runTest<int>();
|
||||
runTest<float>();
|
||||
runTest<long>();
|
||||
runTest<long long>();
|
||||
passed();
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright (c) 2015-present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <hip/hip_runtime.h>
|
||||
#include "test_common.h"
|
||||
|
||||
template <typename T>
|
||||
__global__ void shflDownSum(T* a, int size) {
|
||||
T val = a[threadIdx.x];
|
||||
for (int i = size / 2; i > 0; i /= 2) {
|
||||
val += __shfl_down(val, i, size);
|
||||
}
|
||||
a[threadIdx.x] = val;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__global__ void shflUpSum(T* a, int size) {
|
||||
T val = a[threadIdx.x];
|
||||
for (int i = size / 2; i > 0; i /= 2) {
|
||||
val += __shfl_up(val, i, size);
|
||||
}
|
||||
a[threadIdx.x] = val;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void runTestShflUp() {
|
||||
const int size = 32;
|
||||
T a[size];
|
||||
T cpuSum = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
a[i] = i;
|
||||
cpuSum += a[i];
|
||||
}
|
||||
T* d_a;
|
||||
hipMalloc(&d_a, sizeof(T) * size);
|
||||
hipMemcpy(d_a, &a, sizeof(T) * size, hipMemcpyDefault);
|
||||
hipLaunchKernelGGL(shflUpSum<T>, 1, size, 0, 0, d_a, size);
|
||||
hipMemcpy(&a, d_a, sizeof(T) * size, hipMemcpyDefault);
|
||||
if (a[size - 1] != cpuSum) {
|
||||
hipFree(d_a);
|
||||
failed("Shfl Up Sum did not match.");
|
||||
}
|
||||
hipFree(d_a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void runTestShflDown() {
|
||||
const int size = 32;
|
||||
T a[size];
|
||||
T cpuSum = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
a[i] = i;
|
||||
cpuSum += a[i];
|
||||
}
|
||||
T* d_a;
|
||||
hipMalloc(&d_a, sizeof(T) * size);
|
||||
hipMemcpy(d_a, &a, sizeof(T) * size, hipMemcpyDefault);
|
||||
hipLaunchKernelGGL(shflDownSum<T>, 1, size, 0, 0, d_a, size);
|
||||
hipMemcpy(&a, d_a, sizeof(T) * size, hipMemcpyDefault);
|
||||
if (a[0] != cpuSum) {
|
||||
hipFree(d_a);
|
||||
failed("Shfl Up Sum did not match.");
|
||||
}
|
||||
hipFree(d_a);
|
||||
}
|
||||
int main() {
|
||||
runTestShflUp<int>();
|
||||
runTestShflUp<float>();
|
||||
runTestShflUp<long>();
|
||||
runTestShflUp<long long>();
|
||||
|
||||
runTestShflDown<int>();
|
||||
runTestShflDown<float>();
|
||||
runTestShflDown<long>();
|
||||
runTestShflDown<long long>();
|
||||
passed();
|
||||
}
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ THE SOFTWARE.
|
||||
// Also serves as a template for other tests.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* TEST: %t --memcpyWithPeer EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
* TEST: %t --mirrorPeers EXCLUDE_HIP_PLATFORM hcc vdi
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
template <typename T>
|
||||
void runTest(int width,int height,int depth, hipChannelFormatKind formatKind)
|
||||
{
|
||||
unsigned int size = width * height * depth * sizeof(T);
|
||||
T* hData = (T*) malloc(size);
|
||||
memset(hData, 0, size);
|
||||
|
||||
for (int i = 0; i < depth; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int k = 0; k < width; k++) {
|
||||
hData[i*width*height + j*width +k] = i*width*height + j*width + k;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("test- sizeof(T) =%d\n", sizeof(T));
|
||||
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(sizeof(T)*8, 0, 0, 0, formatKind);
|
||||
hipArray *arr,*arr1;
|
||||
|
||||
HIPCHECK(hipMalloc3DArray(&arr, &channelDesc, make_hipExtent(width, height, depth), hipArrayDefault));
|
||||
HIPCHECK(hipMalloc3DArray(&arr1, &channelDesc, make_hipExtent(width, height, depth), hipArrayDefault));
|
||||
hipMemcpy3DParms myparms = {0};
|
||||
myparms.srcPos = make_hipPos(0,0,0);
|
||||
myparms.dstPos = make_hipPos(0,0,0);
|
||||
myparms.srcPtr = make_hipPitchedPtr(hData, width * sizeof(T), width, height);
|
||||
myparms.dstArray = arr;
|
||||
myparms.extent = make_hipExtent(width , height, depth);
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
myparms.kind = cudaMemcpyHostToDevice;
|
||||
#else
|
||||
myparms.kind = hipMemcpyHostToDevice;
|
||||
#endif
|
||||
HIPCHECK(hipMemcpy3D(&myparms));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
//Array to Array
|
||||
memset(&myparms,0x0, sizeof(hipMemcpy3DParms));
|
||||
myparms.srcPos = make_hipPos(0,0,0);
|
||||
myparms.dstPos = make_hipPos(0,0,0);
|
||||
myparms.srcArray = arr;
|
||||
myparms.dstArray = arr1;
|
||||
myparms.extent = make_hipExtent(width, height, depth);
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
myparms.kind = cudaMemcpyDeviceToDevice;
|
||||
#else
|
||||
myparms.kind = hipMemcpyDeviceToDevice;
|
||||
#endif
|
||||
HIPCHECK(hipMemcpy3D(&myparms));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
|
||||
T *hOutputData = (T*) malloc(size);
|
||||
memset(hOutputData, 0, size);
|
||||
//Device to host
|
||||
memset(&myparms,0x0, sizeof(hipMemcpy3DParms));
|
||||
myparms.srcPos = make_hipPos(0,0,0);
|
||||
myparms.dstPos = make_hipPos(0,0,0);
|
||||
myparms.dstPtr = make_hipPitchedPtr(hOutputData, width * sizeof(T), width, height);
|
||||
myparms.srcArray = arr1;
|
||||
myparms.extent = make_hipExtent(width, height, depth);
|
||||
#ifdef __HIP_PLATFORM_NVCC__
|
||||
myparms.kind = cudaMemcpyDeviceToHost;
|
||||
#else
|
||||
myparms.kind = hipMemcpyDeviceToHost;
|
||||
#endif
|
||||
HIPCHECK(hipMemcpy3D(&myparms));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
|
||||
// Check result
|
||||
HipTest::checkArray(hData,hOutputData,width,height,depth);
|
||||
hipFreeArray(arr);
|
||||
hipFreeArray(arr1);
|
||||
free(hData);
|
||||
free(hOutputData);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
for(int i=1;i<25;i++)
|
||||
{
|
||||
runTest<float>(i,i,i, hipChannelFormatKindFloat);
|
||||
runTest<int>(i+1,i,i, hipChannelFormatKindSigned);
|
||||
runTest<char>(i,i+1,i, hipChannelFormatKindSigned);
|
||||
}
|
||||
passed();
|
||||
}
|
||||
@@ -60,16 +60,16 @@ int main() {
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
HipTest::checkVectorADD(A_h, B_h, C_h, N);
|
||||
|
||||
HIPCHECK(hipStreamCreate(&s));
|
||||
HIPCHECK(hipSetDevice(1));
|
||||
HIPCHECK(hipStreamCreate(&s));
|
||||
HIPCHECK(hipMemcpyPeerAsync(X_d, 1, A_d, 0, Nbytes, s));
|
||||
HIPCHECK(hipMemcpyPeerAsync(Y_d, 1, B_d, 0, Nbytes, s));
|
||||
|
||||
hipLaunchKernelGGL(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0,
|
||||
static_cast<const int*>(X_d), static_cast<const int*>(Y_d), Z_d, N);
|
||||
HIPCHECK(hipMemcpy(C_h, Z_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
HIPCHECK(hipStreamSynchronize(s));
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
HipTest::checkVectorADD(A_h, B_h, C_h, N);
|
||||
|
||||
HIPCHECK(hipStreamDestroy(s));
|
||||
|
||||
@@ -23,7 +23,7 @@ THE SOFTWARE.
|
||||
// Also serves as a template for other tests.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ THE SOFTWARE.
|
||||
// Also serves as a template for other tests.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS --std=c++11 EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS --std=c++11
|
||||
* TEST: %t EXCLUDE_HIP_PLATFORM all
|
||||
* HIT_END
|
||||
|
||||
@@ -32,12 +32,13 @@ THE SOFTWARE.
|
||||
#include "hip/hip_runtime.h"
|
||||
#include "test_common.h"
|
||||
|
||||
#ifdef __HIP_PLATFORM_HCC__
|
||||
#include <hc_am.hpp>
|
||||
#endif
|
||||
|
||||
#define USE_HCC_MEMTRACKER 0 /* Debug flag to show the memtracker periodically */
|
||||
|
||||
#ifndef __HIP_VDI__
|
||||
#include <hc_am.hpp>
|
||||
#else
|
||||
#define USE_HCC_MEMTRACKER 0
|
||||
#endif
|
||||
|
||||
int elementSizes[] = {1, 16, 1024, 524288, 16 * 1000 * 1000};
|
||||
int nSizes = sizeof(elementSizes) / sizeof(int);
|
||||
@@ -202,7 +203,8 @@ int main(int argc, char* argv[]) {
|
||||
};
|
||||
|
||||
for (int index = 0; index < nSizes; index++) {
|
||||
testMultiGpu(dev0, dev1, elementSizes[index], false /*GPU Synchronization*/);
|
||||
//ToDo: Enable when verified on all platforms
|
||||
//testMultiGpu(dev0, dev1, elementSizes[index], false /*GPU Synchronization*/);
|
||||
testMultiGpu(dev0, dev1, elementSizes[index], true /*Host Synchronization*/);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ THE SOFTWARE.
|
||||
// single GPU or multi GPUs.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: matmul.code %hc --genco %S/matmul.cpp -o matmul.code EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD_CMD: matmul.code %hc --genco %S/matmul.cpp -o matmul.code EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp NVCC_OPTIONS -std=c++11 EXCLUDE_HIP_PLATFORM vdi
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
#include "hip/hip_runtime.h"
|
||||
#include "hip/hip_runtime_api.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#define LEN 64
|
||||
#define SIZE LEN << 2
|
||||
#define THREADS 2
|
||||
#define MAX_THREADS 16
|
||||
|
||||
#define FILENAME "vcpy_kernel.code"
|
||||
#define kernel_name "hello_world"
|
||||
|
||||
std::vector<char> load_file()
|
||||
{
|
||||
std::ifstream file(FILENAME, std::ios::binary | std::ios::ate);
|
||||
std::streamsize fsize = file.tellg();
|
||||
file.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<char> buffer(fsize);
|
||||
if (!file.read(buffer.data(), fsize)) {
|
||||
failed("could not open code object '%s'\n", FILENAME);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void run(const std::vector<char>& buffer) {
|
||||
hipDevice_t device;
|
||||
HIPCHECK(hipDeviceGet(&device, 0));
|
||||
hipCtx_t context;
|
||||
HIPCHECK(hipCtxCreate(&context, 0, device));
|
||||
|
||||
hipModule_t Module;
|
||||
hipFunction_t Function;
|
||||
HIPCHECK(hipModuleLoadData(&Module, &buffer[0]));
|
||||
HIPCHECK(hipModuleGetFunction(&Function, Module, kernel_name));
|
||||
|
||||
float *A, *B, *Ad, *Bd;
|
||||
A = new float[LEN];
|
||||
B = new float[LEN];
|
||||
|
||||
for (uint32_t i = 0; i < LEN; i++) {
|
||||
A[i] = i * 1.0f;
|
||||
B[i] = 0.0f;
|
||||
}
|
||||
|
||||
HIPCHECK(hipMalloc((void**)&Ad, SIZE));
|
||||
HIPCHECK(hipMalloc((void**)&Bd, SIZE));
|
||||
|
||||
HIPCHECK(hipMemcpy(Ad, A, SIZE, hipMemcpyHostToDevice));
|
||||
HIPCHECK(hipMemcpy(Bd, B, SIZE, hipMemcpyHostToDevice));
|
||||
|
||||
hipStream_t stream;
|
||||
HIPCHECK(hipStreamCreate(&stream));
|
||||
|
||||
struct {
|
||||
void* _Ad;
|
||||
void* _Bd;
|
||||
} args;
|
||||
args._Ad = (void*) Ad;
|
||||
args._Bd = (void*) Bd;
|
||||
size_t size = sizeof(args);
|
||||
|
||||
void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
HIPCHECK(hipModuleLaunchKernel(Function, 1, 1, 1, LEN, 1, 1, 0, stream, NULL, (void**)&config));
|
||||
|
||||
HIPCHECK(hipStreamDestroy(stream));
|
||||
|
||||
HIPCHECK(hipModuleUnload(Module));
|
||||
|
||||
HIPCHECK(hipMemcpy(B, Bd, SIZE, hipMemcpyDeviceToHost));
|
||||
|
||||
for (uint32_t i = 0; i < LEN; i++) {
|
||||
assert(A[i] == B[i]);
|
||||
}
|
||||
|
||||
hipFree(Ad);
|
||||
hipFree(Bd);
|
||||
delete A;
|
||||
delete B;
|
||||
hipCtxDestroy(context);
|
||||
|
||||
}
|
||||
|
||||
struct joinable_thread : std::thread
|
||||
{
|
||||
template <class... Xs>
|
||||
joinable_thread(Xs&&... xs) : std::thread(std::forward<Xs>(xs)...) // NOLINT
|
||||
{
|
||||
}
|
||||
|
||||
joinable_thread& operator=(joinable_thread&& other) = default;
|
||||
joinable_thread(joinable_thread&& other) = default;
|
||||
|
||||
~joinable_thread()
|
||||
{
|
||||
if(this->joinable())
|
||||
this->join();
|
||||
}
|
||||
};
|
||||
|
||||
void run_multi_threads(uint32_t n, const std::vector<char>& buffer) {
|
||||
|
||||
std::vector<joinable_thread> threads;
|
||||
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
threads.emplace_back(std::thread{[&, buffer] {
|
||||
run(buffer);
|
||||
}});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
HIPCHECK(hipInit(0));
|
||||
auto buffer = load_file();
|
||||
run_multi_threads(min(THREADS * std::thread::hardware_concurrency(), MAX_THREADS), buffer);
|
||||
|
||||
passed();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -33,6 +33,9 @@ THE SOFTWARE.
|
||||
|
||||
#define fileName "tex2d_kernel.code"
|
||||
|
||||
#if __HIP__
|
||||
__hip_pinned_shadow__
|
||||
#endif
|
||||
texture<float, 2, hipReadModeElementType> tex;
|
||||
bool testResult = false;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
// Test the Grid_Launch syntax.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -46,10 +46,8 @@ int main(int argc, char* argv[]) {
|
||||
// test case for using kernel function pointer
|
||||
uint32_t gridSize = 0;
|
||||
uint32_t blockSize = 0;
|
||||
#if defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__)
|
||||
hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, f1, 0, 0);
|
||||
assert(gridSize != 0 && blockSize != 0);
|
||||
#endif
|
||||
|
||||
uint32_t numBlock = 0;
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessor(&numBlock, f1, blockSize, 0);
|
||||
@@ -59,10 +57,8 @@ int main(int argc, char* argv[]) {
|
||||
// test case for using kernel function pointer with template
|
||||
gridSize = 0;
|
||||
blockSize = 0;
|
||||
#if defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__)
|
||||
hipOccupancyMaxPotentialBlockSize<void(*)(int *)>(&gridSize, &blockSize, f2, 0, 0);
|
||||
assert(gridSize != 0 && blockSize != 0);
|
||||
#endif
|
||||
|
||||
numBlock = 0;
|
||||
hipOccupancyMaxActiveBlocksPerMultiprocessor<void(*)(int *)>(&numBlock, f2, blockSize, 0);
|
||||
|
||||
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
// Test the Grid_Launch syntax.
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -46,10 +46,8 @@ int main(int argc, char* argv[]) {
|
||||
// test case for using kernel function pointer
|
||||
uint32_t gridSize = 0;
|
||||
uint32_t blockSize = 0;
|
||||
#if defined(__HIP_PLATFORM_HCC__) && GENERIC_GRID_LAUNCH == 1 && defined(__HCC__)
|
||||
hipOccupancyMaxPotentialBlockSize(&gridSize, &blockSize, f1, 0, 0);
|
||||
assert(gridSize != 0 && blockSize != 0);
|
||||
#endif
|
||||
|
||||
// test case for using kernel function pointer with template
|
||||
gridSize = 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD_CMD: tex2d_kernel.code %hc --genco %S/tex2d_kernel.cpp -o tex2d_kernel.code EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD_CMD: tex2d_kernel.code %hc --genco %S/tex2d_kernel.cpp -o tex2d_kernel.code
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
|
||||
@@ -37,10 +37,12 @@ int p_tests = -1; /*which tests to run. Interpretation is left to each test. de
|
||||
const char* HIP_VISIBLE_DEVICES_STR = "HIP_VISIBLE_DEVICES=";
|
||||
const char* CUDA_VISIBLE_DEVICES_STR = "CUDA_VISIBLE_DEVICES=";
|
||||
const char* PATH_SEPERATOR_STR = "\\";
|
||||
const char* NULL_DEVICE = "NUL:";
|
||||
#else
|
||||
const char* HIP_VISIBLE_DEVICES_STR = "HIP_VISIBLE_DEVICES";
|
||||
const char* CUDA_VISIBLE_DEVICES_STR = "CUDA_VISIBLE_DEVICES";
|
||||
const char* PATH_SEPERATOR_STR = "/";
|
||||
const char* NULL_DEVICE = "/dev/null";
|
||||
#endif
|
||||
|
||||
namespace HipTest {
|
||||
|
||||
@@ -105,6 +105,10 @@ THE SOFTWARE.
|
||||
#define pclose(x) _pclose(x)
|
||||
#define setenv(x,y,z) _putenv_s(x,y)
|
||||
#define unsetenv _putenv
|
||||
#define fileno(x) _fileno(x)
|
||||
#define dup(x) _dup(x)
|
||||
#define dup2(x,y) _dup2(x,y)
|
||||
#define close(x) _close(x)
|
||||
#else
|
||||
#define aligned_free(x) free(x)
|
||||
#endif
|
||||
@@ -124,6 +128,7 @@ extern int p_tests;
|
||||
extern const char* HIP_VISIBLE_DEVICES_STR;
|
||||
extern const char* CUDA_VISIBLE_DEVICES_STR;
|
||||
extern const char* PATH_SEPERATOR_STR;
|
||||
extern const char* NULL_DEVICE;
|
||||
|
||||
// ********************* CPP section *********************
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -18,7 +18,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ THE SOFTWARE.
|
||||
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc hcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -30,78 +30,92 @@ THE SOFTWARE.
|
||||
#define SIZE 10
|
||||
|
||||
static float getNormalizedValue(const float value,
|
||||
const enum hipArray_Format texFormat) {
|
||||
switch (texFormat) {
|
||||
case HIP_AD_FORMAT_SIGNED_INT8:
|
||||
return (value / SCHAR_MAX);
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
||||
return (value / UCHAR_MAX);
|
||||
case HIP_AD_FORMAT_SIGNED_INT16:
|
||||
return (value / SHRT_MAX);
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
||||
return (value / USHRT_MAX);
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
const hipChannelFormatDesc& desc) {
|
||||
if ((desc.x == 8) && (desc.f == hipChannelFormatKindSigned))
|
||||
return (value / SCHAR_MAX);
|
||||
if ((desc.x == 8) && (desc.f == hipChannelFormatKindUnsigned))
|
||||
return (value / UCHAR_MAX);
|
||||
if ((desc.x == 16) && (desc.f == hipChannelFormatKindSigned))
|
||||
return (value / SHRT_MAX);
|
||||
if ((desc.x == 16) && (desc.f == hipChannelFormatKindUnsigned))
|
||||
return (value / USHRT_MAX);
|
||||
return value;
|
||||
}
|
||||
|
||||
#if __HIP__
|
||||
__hip_pinned_shadow__
|
||||
#endif
|
||||
texture<float, hipTextureType1D, hipReadModeElementType> textureNormalizedVal_1D;
|
||||
texture<char, hipTextureType1D, hipReadModeNormalizedFloat> texc;
|
||||
|
||||
#if __HIP__
|
||||
__hip_pinned_shadow__
|
||||
#endif
|
||||
texture<unsigned char, hipTextureType1D, hipReadModeNormalizedFloat> texuc;
|
||||
|
||||
#if __HIP__
|
||||
__hip_pinned_shadow__
|
||||
#endif
|
||||
texture<short, hipTextureType1D, hipReadModeNormalizedFloat> texs;
|
||||
|
||||
#if __HIP__
|
||||
__hip_pinned_shadow__
|
||||
#endif
|
||||
texture<unsigned short, hipTextureType1D, hipReadModeNormalizedFloat> texus;
|
||||
|
||||
|
||||
template<typename T>
|
||||
__global__ void normalizedValTextureTest(unsigned int numElements, float* pDst)
|
||||
{
|
||||
unsigned int elementID = hipThreadIdx_x;
|
||||
if(elementID >= numElements)
|
||||
return;
|
||||
float coord =(float) elementID/(numElements-1);
|
||||
pDst[elementID] = tex1D(textureNormalizedVal_1D, coord);
|
||||
return;
|
||||
float coord =(float) elementID/numElements;
|
||||
if(std::is_same<T, char>::value)
|
||||
pDst[elementID] = tex1D(texc, coord);
|
||||
else if(std::is_same<T, unsigned char>::value)
|
||||
pDst[elementID] = tex1D(texuc, coord);
|
||||
else if(std::is_same<T, short>::value)
|
||||
pDst[elementID] = tex1D(texs, coord);
|
||||
else if(std::is_same<T, unsigned short>::value)
|
||||
pDst[elementID] = tex1D(texus, coord);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool textureTest(enum hipArray_Format texFormat)
|
||||
bool textureTest(texture<T, hipTextureType1D, hipReadModeNormalizedFloat> *tex)
|
||||
{
|
||||
T hData[] = {65, 66, 67, 68, 69, 70, 71, 72,73,74};
|
||||
T *dData = NULL;
|
||||
HIPCHECK(hipMalloc((void **) &dData, sizeof(T)*SIZE));
|
||||
HIPCHECK(hipMemcpyHtoD((hipDeviceptr_t)dData, hData, sizeof(T)*SIZE));
|
||||
textureReference* texRef = &textureNormalizedVal_1D;
|
||||
HIPCHECK(hipTexRefSetAddressMode(texRef, 0, hipAddressModeClamp));
|
||||
HIPCHECK(hipTexRefSetAddressMode(texRef, 1, hipAddressModeClamp));
|
||||
HIPCHECK(hipTexRefSetFilterMode(texRef, hipFilterModePoint));
|
||||
HIPCHECK(hipTexRefSetFlags(texRef, HIP_TRSF_NORMALIZED_COORDINATES));
|
||||
HIPCHECK(hipTexRefSetFormat(texRef, texFormat, 1));
|
||||
|
||||
HIP_ARRAY_DESCRIPTOR desc;
|
||||
desc.Width = SIZE;
|
||||
desc.Height = 1;
|
||||
desc.Format = texFormat;
|
||||
desc.NumChannels = 1;
|
||||
HIPCHECK(hipTexRefSetAddress2D(texRef, &desc, (hipDeviceptr_t)dData, sizeof(T)*SIZE));
|
||||
|
||||
bool testResult = true;
|
||||
hipChannelFormatDesc desc = hipCreateChannelDesc<T>();
|
||||
hipArray_t dData;
|
||||
HIPCHECK(hipMallocArray(&dData, &desc, SIZE, 1, hipArrayDefault));
|
||||
|
||||
T hData[] = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74};
|
||||
HIPCHECK(hipMemcpy2DToArray(dData, 0, 0, hData, sizeof(T)*SIZE, sizeof(T)*SIZE, 1, hipMemcpyHostToDevice));
|
||||
|
||||
tex->normalized = true;
|
||||
tex->channelDesc = desc;
|
||||
HIPCHECK(hipBindTextureToArray(tex, dData, &desc));
|
||||
|
||||
float *dOutputData = NULL;
|
||||
HIPCHECK(hipMalloc((void **) &dOutputData, sizeof(float)*SIZE));
|
||||
|
||||
hipLaunchKernelGGL(HIP_KERNEL_NAME(normalizedValTextureTest), dim3(1,1,1), dim3(SIZE,1,1), 0, 0, SIZE, dOutputData);
|
||||
|
||||
hipLaunchKernelGGL(normalizedValTextureTest<T>, dim3(1,1,1), dim3(SIZE,1,1), 0, 0, SIZE, dOutputData);
|
||||
|
||||
float *hOutputData = new float[SIZE];
|
||||
HIPCHECK(hipMemcpyDtoH(hOutputData, (hipDeviceptr_t)dOutputData, (sizeof(float)*SIZE)));
|
||||
|
||||
HIPCHECK(hipMemcpy(hOutputData, dOutputData, (sizeof(float)*SIZE), hipMemcpyDeviceToHost));
|
||||
|
||||
bool testResult = true;
|
||||
for(int i = 0; i < SIZE; i++)
|
||||
{
|
||||
float expected = getNormalizedValue(float(hData[i]), texFormat);
|
||||
float expected = getNormalizedValue(float(hData[i]), desc);
|
||||
if(expected != hOutputData[i])
|
||||
{
|
||||
printf("mismatch at index:%d for texType:%d output:%f\n",i,texFormat,hOutputData[i]);
|
||||
printf("mismatch at index:%d output:%f expected:%f\n",i,hOutputData[i],expected);
|
||||
testResult = false;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hipFree(dData);
|
||||
hipFree(dOutputData);
|
||||
hipUnbindTexture(textureNormalizedVal_1D);
|
||||
|
||||
HIPCHECK(hipFreeArray(dData));
|
||||
HIPCHECK(hipFree(dOutputData));
|
||||
delete [] hOutputData;
|
||||
return testResult;
|
||||
}
|
||||
@@ -118,12 +132,11 @@ int main(int argc, char** argv)
|
||||
std::cout << "Arch - AMD GPU :: " << props.gcnArch << std::endl;
|
||||
#endif
|
||||
|
||||
status &= textureTest<char> (HIP_AD_FORMAT_SIGNED_INT8);
|
||||
status &= textureTest<unsigned char> (HIP_AD_FORMAT_UNSIGNED_INT8);
|
||||
status &= textureTest<short> (HIP_AD_FORMAT_SIGNED_INT16);
|
||||
status &= textureTest<unsigned short>(HIP_AD_FORMAT_UNSIGNED_INT16);
|
||||
status &= textureTest<float> (HIP_AD_FORMAT_FLOAT);
|
||||
|
||||
status &= textureTest<char> (&texc);
|
||||
status &= textureTest<unsigned char> (&texuc);
|
||||
status &= textureTest<short> (&texs);
|
||||
status &= textureTest<unsigned short>(&texus);
|
||||
|
||||
if(status){
|
||||
passed();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM vdi
|
||||
* BUILD: %t %s ../test_common.cpp
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* HIT_START
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc vdi
|
||||
* BUILD: %t %s ../test_common.cpp EXCLUDE_HIP_PLATFORM nvcc
|
||||
* TEST: %t
|
||||
* HIT_END
|
||||
*/
|
||||
@@ -52,16 +52,16 @@ __global__ void simpleKernel3DArray(T* outputData,
|
||||
int height,int depth)
|
||||
{
|
||||
for (int i = 0; i < depth; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int k = 0; k < width; k++) {
|
||||
if(std::is_same<T, float>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texf, texf.textureObject, k, j, i);
|
||||
else if(std::is_same<T, int>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texi, texi.textureObject, k, j, i);
|
||||
else if(std::is_same<T, char>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texc, texc.textureObject, k, j, i);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int k = 0; k < width; k++) {
|
||||
if(std::is_same<T, float>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texf, k, j, i);
|
||||
else if(std::is_same<T, int>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texi, k, j, i);
|
||||
else if(std::is_same<T, char>::value)
|
||||
outputData[i*width*height + j*width + k] = tex3D(texc, k, j, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ void runTest(int width,int height,int depth,texture<T, hipTextureType3D, hipRead
|
||||
}
|
||||
|
||||
// Allocate array and copy image data
|
||||
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(sizeof(T)*8, 0, 0, 0, hipChannelFormatKindSigned);
|
||||
hipChannelFormatDesc channelDesc = hipCreateChannelDesc<T>();
|
||||
hipArray *arr;
|
||||
|
||||
HIPCHECK(hipMalloc3DArray(&arr, &channelDesc, make_hipExtent(width, height, depth), hipArrayCubemap));
|
||||
HIPCHECK(hipMalloc3DArray(&arr, &channelDesc, make_hipExtent(width, height, depth), hipArrayDefault));
|
||||
hipMemcpy3DParms myparms = {0};
|
||||
myparms.srcPos = make_hipPos(0,0,0);
|
||||
myparms.dstPos = make_hipPos(0,0,0);
|
||||
|
||||
+38
-61
@@ -1,6 +1,5 @@
|
||||
#project("hip")
|
||||
cmake_minimum_required(VERSION 3.5.1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-keep-memory -Wl,-Bsymbolic -Wl,--unresolved-symbols=report-all -Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/hip_hcc.map.in")
|
||||
|
||||
@@ -9,24 +8,23 @@ if(CMAKE_CXX_FLAGS MATCHES "fsanitize=address")
|
||||
endif()
|
||||
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
||||
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/hip)
|
||||
|
||||
add_definitions(-D__HIP_VDI__ -D__HIP_PLATFORM_HCC__ -DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER -DUSE_PROF_API)
|
||||
add_definitions(-D__HIP_VDI__ -D__HIP_PLATFORM_HCC__ -DLINUX -D__x86_64__ -D__AMD64__ -DUNIX_OS -DqLittleEndian -DOPENCL_MAJOR=2 -DOPENCL_MINOR=0 -DCL_TARGET_OPENCL_VERSION=220 -DWITH_AQL -DWITH_ONLINE_COMPILER -DATI_OS_LINUX -DATI_ARCH_X86 -DLITTLEENDIAN_CPU -DATI_BITS_64 -DATI_COMP_GCC -DWITH_HSA_DEVICE -DWITH_TARGET_AMDGCN -DOPENCL_EXPORTS -DCL_USE_DEPRECATED_OPENCL_1_0_APIS -DCL_USE_DEPRECATED_OPENCL_1_1_APIS -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_0_APIS -DVEGA10_ONLY=false -DWITH_LIGHTNING_COMPILER -DUSE_PROF_API)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
add_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
#command example:
|
||||
#cmake -DVDI_DIR=/home/pghafari/vdi/vdi -DLIBOCL_STATIC_DIR=/home/pghafari/git-ocl/build/amdocl -DLIBVDI_STATIC_DIR=/home/pghafari/vdi/vdi/build -DUSE_COMGR_LIBRARY=yes -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="/home/pghafari/rocmgitvdi/hsa-runtime/opensrc/hsa-runtime/build;/home/pghafari/rocmgitvdi/hsa-runtime/opensrc;/home/pghafari/rocmgitvdi/support/lib/comgr;/home/pghafari/rocmgitvdi/support/lib/comgr/build;" -DCMAKE_MODULE_PATH=/home/pghafari/rocmgit/opencl/cmake/modules -DLLVM_INCLUDES=/home/pghafari/rocmgit/llvm-project/llvm/include ..
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options("-Wno-ignored-attributes")
|
||||
endif()
|
||||
|
||||
set(USE_PROF_API "1")
|
||||
|
||||
find_package(ROCT REQUIRED)
|
||||
find_package(ROCR REQUIRED)
|
||||
|
||||
if(NOT DEFINED LIBVDI_STATIC_DIR)
|
||||
find_path(LIBVDI_STATIC_DIR
|
||||
NAMES libamdvdi_static.a
|
||||
@@ -42,7 +40,7 @@ if(NOT DEFINED VDI_DIR)
|
||||
PATHS /opt/rocm/vdi
|
||||
)
|
||||
endif()
|
||||
message("vdilib:${LIBVDI_STATIC_DIR} ,found vdi includes ${VDI_DIR}")
|
||||
message("Found Static vdi lib:${LIBVDI_STATIC_DIR} and vdi includes: ${VDI_DIR}")
|
||||
set(PROF_API_HEADER_PATH ${VDI_DIR}/platform)
|
||||
#############################
|
||||
# Profiling API support
|
||||
@@ -56,7 +54,7 @@ set(PROF_API_LOG "${PROJECT_BINARY_DIR}/hip_prof_gen.log.txt")
|
||||
set(PROF_API_CMD "${PROF_API_GEN} -v -t --priv ${OPT_PROF_API} ${PROF_API_HDR} ${PROF_API_SRC} ${PROF_API_STR} >${PROF_API_LOG}")
|
||||
MESSAGE(STATUS "Generating profiling promitives: ${PROF_API_STR}")
|
||||
execute_process(COMMAND sh -c "rm -f ${PROF_API_STR}; ${PROF_API_CMD}")
|
||||
MESSAGE(COMMAND sh -c "rm -f ${PROF_API_STR}; ${PROF_API_CMD}")
|
||||
#MESSAGE(COMMAND sh -c "rm -f ${PROF_API_STR}; ${PROF_API_CMD}")
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PROF_API_GEN} ${PROF_API_HDR} ${PROF_API_STR})
|
||||
|
||||
# Enable profiling API
|
||||
@@ -92,7 +90,6 @@ if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
include_directories(${LLVM_INCLUDES})
|
||||
endif() # if (DEFINED LLVM_INCLUDES AND NOT ${LLVM_INCLUDES} STREQUAL "")
|
||||
|
||||
#find_package(hsa-runtime REQUIRED CONFIG PATHS ${HSA_RUNTIME} NO_DEFAULT_PATH)
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/elfio)
|
||||
@@ -102,9 +99,8 @@ include_directories(${VDI_DIR})
|
||||
include_directories(${VDI_DIR}/include)
|
||||
include_directories(${VDI_DIR}/compiler/lib)
|
||||
include_directories(${VDI_DIR}/compiler/lib/include)
|
||||
include_directories(${VDI_DIR}/compiler/lib/loaders)
|
||||
include_directories(${VDI_DIR}/compiler/lib/loaders/elf/utils/common)
|
||||
include_directories(${VDI_DIR}/compiler/lib/loaders/elf/utils/libelf)
|
||||
include_directories(${VDI_DIR}/elf/utils/common)
|
||||
include_directories(${VDI_DIR}/elf/utils/libelf)
|
||||
add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
find_package(amd_comgr REQUIRED CONFIG
|
||||
PATHS
|
||||
@@ -115,14 +111,11 @@ add_definitions(-DUSE_COMGR_LIBRARY -DCOMGR_DYN_DLL)
|
||||
)
|
||||
MESSAGE(STATUS "Code Object Manager found at ${amd_comgr_DIR}.")
|
||||
|
||||
#find_package(amd_comgr REQUIRED CONFIG)
|
||||
include_directories("$<TARGET_PROPERTY:amd_comgr,INTERFACE_INCLUDE_DIRECTORIES>")
|
||||
|
||||
add_definitions(-DBSD_LIBELF)
|
||||
#find_package( Threads REQUIRED CONFIG)
|
||||
#find_package( LibElf REQUIRED CONFIG)
|
||||
|
||||
add_library(amdhip64 SHARED
|
||||
add_library(hip64 OBJECT
|
||||
hip_context.cpp
|
||||
hip_device.cpp
|
||||
hip_device_runtime.cpp
|
||||
@@ -143,24 +136,37 @@ add_library(amdhip64 SHARED
|
||||
cl_lqdflash_amd.cpp
|
||||
fixme.cpp
|
||||
)
|
||||
add_library(amdvdi_static STATIC IMPORTED)
|
||||
set_target_properties(amdvdi_static PROPERTIES IMPORTED_LOCATION "${LIBVDI_STATIC_DIR}/libamdvdi_static.a")
|
||||
#add_library(amdocl64 SHARED IMPORTED)
|
||||
#set_target_properties(amdocl64 PROPERTIES IMPORTED_LOCATION "/opt/rocm/opencl/lib/x86_64/libamdocl64.so")
|
||||
#add_library(oclelf STATIC IMPORTED)
|
||||
#set_target_properties(oclelf PROPERTIES IMPORTED_LOCATION "${LIBOCLELF_STATIC_DIR}/liboclelf.a")
|
||||
set_target_properties(hip64 PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(
|
||||
hip64 PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
add_library(host INTERFACE)
|
||||
target_link_libraries(host INTERFACE amdhip64)
|
||||
add_library(device INTERFACE)
|
||||
target_link_libraries(device INTERFACE host)
|
||||
#target_link_libraries(amdhip64 PRIVATE amd_comgr)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
include(${LIBVDI_STATIC_DIR}/amdvdi_staticTargets.cmake)
|
||||
|
||||
target_link_libraries(amdhip64 amdvdi_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
#target_link_libraries(amdhip64 amdvdi_static amdocl64_static pthread dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES})
|
||||
add_library(amdhip64 SHARED
|
||||
$<TARGET_OBJECTS:hip64>
|
||||
)
|
||||
|
||||
#install(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhip_hcc.so)" )
|
||||
add_library(amdhip64_static STATIC
|
||||
$<TARGET_OBJECTS:hip64>
|
||||
)
|
||||
|
||||
add_library(host INTERFACE)
|
||||
target_link_libraries(host INTERFACE amdhip64)
|
||||
target_link_libraries(host INTERFACE amdhip64_static)
|
||||
add_library(device INTERFACE)
|
||||
target_link_libraries(device INTERFACE host)
|
||||
|
||||
target_link_libraries(amdhip64_static amdvdi_static pthread dl)
|
||||
target_link_libraries(amdhip64 amdvdi_static pthread dl)
|
||||
|
||||
|
||||
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64_static> DESTINATION lib COMPONENT MAIN)
|
||||
INSTALL(PROGRAMS $<TARGET_FILE:amdhip64> DESTINATION lib COMPONENT MAIN)
|
||||
INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink libamdhip64.so lib/libhip_hcc.so )" DESTINATION lib COMPONENT MAIN)
|
||||
|
||||
@@ -169,35 +175,6 @@ INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhip_hcc.so DESTINATION lib COMPONENT MA
|
||||
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/libhiprtc.so DESTINATION lib COMPONENT MAIN)
|
||||
|
||||
INSTALL(TARGETS amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR})
|
||||
INSTALL(TARGETS amdhip64_static amdhip64 host device EXPORT hip-targets DESTINATION ${LIB_INSTALL_DIR})
|
||||
INSTALL(EXPORT hip-targets DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} NAMESPACE hip::)
|
||||
|
||||
if(0)
|
||||
set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators")
|
||||
|
||||
set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.")
|
||||
set(CPACK_PACKAGE_VENDOR "AMD")
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm/hip-on-vdi")
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||
|
||||
# Debian CPACK variables
|
||||
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_DEBIAN_MAIN_FILE_NAME "hip-on-vdi-1.0.0.deb")
|
||||
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "hip-on-vdi")
|
||||
#set(CPACK_DEBIAN_MAIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEB/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEB/prerm")
|
||||
|
||||
# RPM CPACK variables
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
|
||||
set(CPACK_RPM_MAIN_FILE_NAME "hip-on-vdi-1.0.0.rpm")
|
||||
set(CPACK_RPM_MAIN_PACKAGE_NAME "hip-on-vdi")
|
||||
#set(CPACK_RPM_MAIN_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post")
|
||||
#set(CPACK_RPM_MAIN_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun")
|
||||
|
||||
set(CPACK_COMPONENTS_ALL MAIN)
|
||||
include(CPack)
|
||||
endif()
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
#include "vdi_common.hpp"
|
||||
#include <icd/loader/icd_dispatch.h>
|
||||
|
||||
KHRicdVendorDispatch amd::ICDDispatchedObject::icdVendorDispatch_[] = {0};
|
||||
cl_icd_dispatch amd::ICDDispatchedObject::icdVendorDispatch_[] = {0};
|
||||
amd::PlatformIDS amd::PlatformID::Platform = {amd::ICDDispatchedObject::icdVendorDispatch_};
|
||||
|
||||
RUNTIME_ENTRY(cl_int, clGetDeviceIDs,
|
||||
|
||||
@@ -50,6 +50,9 @@ void init() {
|
||||
amd::Context* context = new amd::Context(device, amd::Context::Info());
|
||||
if (!context) return;
|
||||
|
||||
// Enable active wait on the device by default
|
||||
devices[i]->SetActiveWait(true);
|
||||
|
||||
if (context && CL_SUCCESS != context->create(nullptr)) {
|
||||
context->release();
|
||||
} else {
|
||||
@@ -103,6 +106,7 @@ amd::HostQueue* getNullStream(Device& dev) {
|
||||
}
|
||||
return stream->second;
|
||||
}
|
||||
|
||||
amd::HostQueue* getNullStream(amd::Context& ctx) {
|
||||
for (auto& it : g_nullStreams) {
|
||||
if (it.first->asContext() == &ctx) {
|
||||
|
||||
@@ -0,0 +1,898 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hip/hcc_detail/driver_types.h>
|
||||
#include <hip/hcc_detail/texture_types.h>
|
||||
|
||||
namespace hip
|
||||
{
|
||||
inline
|
||||
cl_channel_type getCLChannelType(const hipArray_Format hipFormat,
|
||||
const hipTextureReadMode hipReadMode) {
|
||||
if (hipReadMode == hipReadModeElementType) {
|
||||
switch (hipFormat) {
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
||||
return CL_UNSIGNED_INT8;
|
||||
case HIP_AD_FORMAT_SIGNED_INT8:
|
||||
return CL_SIGNED_INT8;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
||||
return CL_UNSIGNED_INT16;
|
||||
case HIP_AD_FORMAT_SIGNED_INT16:
|
||||
return CL_SIGNED_INT16;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT32:
|
||||
return CL_UNSIGNED_INT32;
|
||||
case HIP_AD_FORMAT_SIGNED_INT32:
|
||||
return CL_SIGNED_INT32;
|
||||
case HIP_AD_FORMAT_HALF:
|
||||
return CL_HALF_FLOAT;
|
||||
case HIP_AD_FORMAT_FLOAT:
|
||||
return CL_FLOAT;
|
||||
}
|
||||
} else if (hipReadMode == hipReadModeNormalizedFloat) {
|
||||
switch (hipFormat) {
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
||||
return CL_UNORM_INT8;
|
||||
case HIP_AD_FORMAT_SIGNED_INT8:
|
||||
return CL_SNORM_INT8;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
||||
return CL_UNORM_INT16;
|
||||
case HIP_AD_FORMAT_SIGNED_INT16:
|
||||
return CL_SNORM_INT16;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT32:
|
||||
return CL_UNSIGNED_INT32;
|
||||
case HIP_AD_FORMAT_SIGNED_INT32:
|
||||
return CL_SIGNED_INT32;
|
||||
case HIP_AD_FORMAT_HALF:
|
||||
return CL_HALF_FLOAT;
|
||||
case HIP_AD_FORMAT_FLOAT:
|
||||
return CL_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
cl_channel_order getCLChannelOrder(const unsigned int hipNumChannels,
|
||||
const int sRGB) {
|
||||
switch (hipNumChannels) {
|
||||
case 1:
|
||||
return CL_R;
|
||||
case 2:
|
||||
return CL_RG;
|
||||
case 4:
|
||||
return (sRGB == 1) ? CL_sRGBA : CL_RGBA;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
cl_mem_object_type getCLMemObjectType(const unsigned int hipWidth,
|
||||
const unsigned int hipHeight,
|
||||
const unsigned int hipDepth,
|
||||
const unsigned int flags) {
|
||||
if (flags == hipArrayDefault) {
|
||||
if ((hipWidth != 0) && (hipHeight == 0) && (hipDepth == 0)) {
|
||||
return CL_MEM_OBJECT_IMAGE1D;
|
||||
} else if ((hipWidth != 0) && (hipHeight != 0) && (hipDepth == 0)) {
|
||||
return CL_MEM_OBJECT_IMAGE2D;
|
||||
} else if ((hipWidth != 0) && (hipHeight != 0) && (hipDepth != 0)) {
|
||||
return CL_MEM_OBJECT_IMAGE3D;
|
||||
}
|
||||
} else if (flags == hipArrayLayered) {
|
||||
if ((hipWidth != 0) && (hipHeight == 0) && (hipDepth != 0)) {
|
||||
return CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
} else if ((hipWidth != 0) && (hipHeight != 0) && (hipDepth != 0)) {
|
||||
return CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
cl_addressing_mode getCLAddressingMode(const hipTextureAddressMode hipAddressMode) {
|
||||
switch (hipAddressMode) {
|
||||
case hipAddressModeWrap:
|
||||
return CL_ADDRESS_REPEAT;
|
||||
case hipAddressModeClamp:
|
||||
return CL_ADDRESS_CLAMP;
|
||||
case hipAddressModeMirror:
|
||||
return CL_ADDRESS_MIRRORED_REPEAT;
|
||||
case hipAddressModeBorder:
|
||||
return CL_ADDRESS_CLAMP_TO_EDGE;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
cl_filter_mode getCLFilterMode(const hipTextureFilterMode hipFilterMode) {
|
||||
switch (hipFilterMode) {
|
||||
case hipFilterModePoint:
|
||||
return CL_FILTER_NEAREST;
|
||||
case hipFilterModeLinear:
|
||||
return CL_FILTER_LINEAR;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
cl_mem_object_type getCLMemObjectType(const hipResourceType hipResType) {
|
||||
switch (hipResType) {
|
||||
case hipResourceTypeLinear:
|
||||
return CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||
case hipResourceTypePitch2D:
|
||||
return CL_MEM_OBJECT_IMAGE2D;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
size_t getElementSize(const hipArray_Format arrayFormat) {
|
||||
switch (arrayFormat) {
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
||||
case HIP_AD_FORMAT_SIGNED_INT8:
|
||||
return 1;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
||||
case HIP_AD_FORMAT_SIGNED_INT16:
|
||||
case HIP_AD_FORMAT_HALF:
|
||||
return 2;
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT32:
|
||||
case HIP_AD_FORMAT_SIGNED_INT32:
|
||||
case HIP_AD_FORMAT_FLOAT:
|
||||
return 4;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
hipChannelFormatDesc getChannelFormatDesc(int numChannels,
|
||||
hipArray_Format arrayFormat) {
|
||||
switch (arrayFormat) {
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {8, 0, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 2:
|
||||
return {8, 8, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 4:
|
||||
return {8, 8, 8, 8, hipChannelFormatKindUnsigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_SIGNED_INT8:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {8, 0, 0, 0, hipChannelFormatKindSigned};
|
||||
case 2:
|
||||
return {8, 8, 0, 0, hipChannelFormatKindSigned};
|
||||
case 4:
|
||||
return {8, 8, 8, 8, hipChannelFormatKindSigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {16, 0, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 2:
|
||||
return {16, 16, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 4:
|
||||
return {16, 16, 16, 16, hipChannelFormatKindUnsigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_SIGNED_INT16:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {16, 0, 0, 0, hipChannelFormatKindSigned};
|
||||
case 2:
|
||||
return {16, 16, 0, 0, hipChannelFormatKindSigned};
|
||||
case 4:
|
||||
return {16, 16, 16, 16, hipChannelFormatKindSigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_UNSIGNED_INT32:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {32, 0, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 2:
|
||||
return {32, 32, 0, 0, hipChannelFormatKindUnsigned};
|
||||
case 4:
|
||||
return {32, 32, 32, 32, hipChannelFormatKindUnsigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_SIGNED_INT32:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {32, 0, 0, 0, hipChannelFormatKindSigned};
|
||||
case 2:
|
||||
return {32, 32, 0, 0, hipChannelFormatKindSigned};
|
||||
case 4:
|
||||
return {32, 32, 32, 32, hipChannelFormatKindSigned};
|
||||
}
|
||||
case HIP_AD_FORMAT_HALF:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {16, 0, 0, 0, hipChannelFormatKindFloat};
|
||||
case 2:
|
||||
return {16, 16, 0, 0, hipChannelFormatKindFloat};
|
||||
case 4:
|
||||
return {16, 16, 16, 16, hipChannelFormatKindFloat};
|
||||
}
|
||||
case HIP_AD_FORMAT_FLOAT:
|
||||
switch (numChannels) {
|
||||
case 1:
|
||||
return {32, 0, 0, 0, hipChannelFormatKindFloat};
|
||||
case 2:
|
||||
return {32, 32, 0, 0, hipChannelFormatKindFloat};
|
||||
case 4:
|
||||
return {32, 32, 32, 32, hipChannelFormatKindFloat};
|
||||
}
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int getNumChannels(const hipChannelFormatDesc& desc) {
|
||||
return ((desc.x != 0) + (desc.y != 0) + (desc.z != 0) + (desc.w != 0));
|
||||
}
|
||||
|
||||
inline
|
||||
hipArray_Format getArrayFormat(const hipChannelFormatDesc& desc) {
|
||||
switch (desc.f) {
|
||||
case hipChannelFormatKindUnsigned:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT8;
|
||||
case 16:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT16;
|
||||
case 32:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT32;
|
||||
}
|
||||
case hipChannelFormatKindSigned:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return HIP_AD_FORMAT_SIGNED_INT8;
|
||||
case 16:
|
||||
return HIP_AD_FORMAT_SIGNED_INT16;
|
||||
case 32:
|
||||
return HIP_AD_FORMAT_SIGNED_INT32;
|
||||
}
|
||||
case hipChannelFormatKindFloat:
|
||||
switch (desc.x) {
|
||||
case 16:
|
||||
return HIP_AD_FORMAT_HALF;
|
||||
case 32:
|
||||
return HIP_AD_FORMAT_FLOAT;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
int getNumChannels(const hipResourceViewFormat hipFormat) {
|
||||
switch (hipFormat) {
|
||||
case hipResViewFormatUnsignedChar1:
|
||||
case hipResViewFormatSignedChar1:
|
||||
case hipResViewFormatUnsignedShort1:
|
||||
case hipResViewFormatSignedShort1:
|
||||
case hipResViewFormatUnsignedInt1:
|
||||
case hipResViewFormatSignedInt1:
|
||||
case hipResViewFormatHalf1:
|
||||
case hipResViewFormatFloat1:
|
||||
return 1;
|
||||
case hipResViewFormatUnsignedChar2:
|
||||
case hipResViewFormatSignedChar2:
|
||||
case hipResViewFormatUnsignedShort2:
|
||||
case hipResViewFormatSignedShort2:
|
||||
case hipResViewFormatUnsignedInt2:
|
||||
case hipResViewFormatSignedInt2:
|
||||
case hipResViewFormatHalf2:
|
||||
case hipResViewFormatFloat2:
|
||||
return 2;
|
||||
case hipResViewFormatUnsignedChar4:
|
||||
case hipResViewFormatSignedChar4:
|
||||
case hipResViewFormatUnsignedShort4:
|
||||
case hipResViewFormatSignedShort4:
|
||||
case hipResViewFormatUnsignedInt4:
|
||||
case hipResViewFormatSignedInt4:
|
||||
case hipResViewFormatHalf4:
|
||||
case hipResViewFormatFloat4:
|
||||
return 4;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
hipArray_Format getArrayFormat(const hipResourceViewFormat hipFormat) {
|
||||
switch (hipFormat) {
|
||||
case hipResViewFormatUnsignedChar1:
|
||||
case hipResViewFormatUnsignedChar2:
|
||||
case hipResViewFormatUnsignedChar4:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT8;
|
||||
case hipResViewFormatSignedChar1:
|
||||
case hipResViewFormatSignedChar2:
|
||||
case hipResViewFormatSignedChar4:
|
||||
return HIP_AD_FORMAT_SIGNED_INT8;
|
||||
case hipResViewFormatUnsignedShort1:
|
||||
case hipResViewFormatUnsignedShort2:
|
||||
case hipResViewFormatUnsignedShort4:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT16;
|
||||
case hipResViewFormatSignedShort1:
|
||||
case hipResViewFormatSignedShort2:
|
||||
case hipResViewFormatSignedShort4:
|
||||
return HIP_AD_FORMAT_SIGNED_INT16;
|
||||
case hipResViewFormatUnsignedInt1:
|
||||
case hipResViewFormatUnsignedInt2:
|
||||
case hipResViewFormatUnsignedInt4:
|
||||
return HIP_AD_FORMAT_UNSIGNED_INT32;
|
||||
case hipResViewFormatSignedInt1:
|
||||
case hipResViewFormatSignedInt2:
|
||||
case hipResViewFormatSignedInt4:
|
||||
return HIP_AD_FORMAT_SIGNED_INT32;
|
||||
case hipResViewFormatHalf1:
|
||||
case hipResViewFormatHalf2:
|
||||
case hipResViewFormatHalf4:
|
||||
return HIP_AD_FORMAT_HALF;
|
||||
case hipResViewFormatFloat1:
|
||||
case hipResViewFormatFloat2:
|
||||
case hipResViewFormatFloat4:
|
||||
return HIP_AD_FORMAT_FLOAT;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceViewFormat getResourceViewFormat(const hipChannelFormatDesc& desc) {
|
||||
switch (desc.f) {
|
||||
case hipChannelFormatKindUnsigned:
|
||||
switch (getNumChannels(desc)) {
|
||||
case 1:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatUnsignedChar1;
|
||||
case 16:
|
||||
return hipResViewFormatUnsignedShort1;
|
||||
case 32:
|
||||
return hipResViewFormatUnsignedInt1;
|
||||
}
|
||||
case 2:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatUnsignedChar2;
|
||||
case 16:
|
||||
return hipResViewFormatUnsignedShort2;
|
||||
case 32:
|
||||
return hipResViewFormatUnsignedInt2;
|
||||
}
|
||||
case 4:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatUnsignedChar4;
|
||||
case 16:
|
||||
return hipResViewFormatUnsignedShort4;
|
||||
case 32:
|
||||
return hipResViewFormatUnsignedInt4;
|
||||
}
|
||||
}
|
||||
case hipChannelFormatKindSigned:
|
||||
switch (getNumChannels(desc)) {
|
||||
case 1:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatSignedChar1;
|
||||
case 16:
|
||||
return hipResViewFormatSignedShort1;
|
||||
case 32:
|
||||
return hipResViewFormatSignedInt1;
|
||||
}
|
||||
case 2:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatSignedChar2;
|
||||
case 16:
|
||||
return hipResViewFormatSignedShort2;
|
||||
case 32:
|
||||
return hipResViewFormatSignedInt2;
|
||||
}
|
||||
case 4:
|
||||
switch (desc.x) {
|
||||
case 8:
|
||||
return hipResViewFormatSignedChar4;
|
||||
case 16:
|
||||
return hipResViewFormatSignedShort4;
|
||||
case 32:
|
||||
return hipResViewFormatSignedInt4;
|
||||
}
|
||||
}
|
||||
case hipChannelFormatKindFloat:
|
||||
switch (getNumChannels(desc)) {
|
||||
case 1:
|
||||
switch (desc.x) {
|
||||
case 16:
|
||||
return hipResViewFormatHalf1;
|
||||
case 32:
|
||||
return hipResViewFormatFloat1;
|
||||
}
|
||||
case 2:
|
||||
switch (desc.x) {
|
||||
case 16:
|
||||
return hipResViewFormatHalf2;
|
||||
case 32:
|
||||
return hipResViewFormatFloat2;
|
||||
}
|
||||
case 4:
|
||||
switch (desc.x) {
|
||||
case 16:
|
||||
return hipResViewFormatHalf4;
|
||||
case 32:
|
||||
return hipResViewFormatFloat4;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
hipTextureDesc getTextureDesc(const textureReference* texRef) {
|
||||
hipTextureDesc texDesc = {};
|
||||
std::memcpy(texDesc.addressMode, texRef->addressMode, sizeof(texDesc.addressMode));
|
||||
texDesc.filterMode = texRef->filterMode;
|
||||
texDesc.readMode = texRef->readMode;
|
||||
texDesc.sRGB = texRef->sRGB;
|
||||
texDesc.normalizedCoords = texRef->normalized;
|
||||
texDesc.maxAnisotropy = texRef->maxAnisotropy;
|
||||
texDesc.mipmapFilterMode = texRef->mipmapFilterMode;
|
||||
texDesc.mipmapLevelBias = texRef->mipmapLevelBias;
|
||||
texDesc.minMipmapLevelClamp = texRef->minMipmapLevelClamp;
|
||||
texDesc.maxMipmapLevelClamp = texRef->maxMipmapLevelClamp;
|
||||
|
||||
return texDesc;
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceViewDesc getResourceViewDesc(hipArray_const_t array,
|
||||
const hipResourceViewFormat format) {
|
||||
hipResourceViewDesc resViewDesc = {};
|
||||
resViewDesc.format = format;
|
||||
resViewDesc.width = array->width;
|
||||
resViewDesc.height = array->height;
|
||||
resViewDesc.depth = array->depth;
|
||||
resViewDesc.firstMipmapLevel = 0;
|
||||
resViewDesc.lastMipmapLevel = 0;
|
||||
resViewDesc.firstLayer = 0;
|
||||
resViewDesc.lastLayer = 0; /* TODO add hipArray::numLayers */
|
||||
|
||||
return resViewDesc;
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceViewDesc getResourceViewDesc(hipMipmappedArray_const_t array,
|
||||
const hipResourceViewFormat format) {
|
||||
hipResourceViewDesc resViewDesc = {};
|
||||
resViewDesc.format = format;
|
||||
resViewDesc.width = array->width;
|
||||
resViewDesc.height = array->height;
|
||||
resViewDesc.depth = array->depth;
|
||||
resViewDesc.firstMipmapLevel = 0;
|
||||
resViewDesc.lastMipmapLevel = 0; /* TODO add hipMipmappedArray::numMipLevels */
|
||||
resViewDesc.firstLayer = 0;
|
||||
resViewDesc.lastLayer = 0; /* TODO add hipArray::numLayers */
|
||||
|
||||
return resViewDesc;
|
||||
}
|
||||
|
||||
inline
|
||||
std::pair<hipMemoryType, hipMemoryType> getMemoryType(const hipMemcpyKind kind) {
|
||||
switch (kind) {
|
||||
case hipMemcpyHostToHost:
|
||||
return {hipMemoryTypeHost, hipMemoryTypeHost};
|
||||
case hipMemcpyHostToDevice:
|
||||
return {hipMemoryTypeHost, hipMemoryTypeDevice};
|
||||
case hipMemcpyDeviceToHost:
|
||||
return {hipMemoryTypeDevice, hipMemoryTypeHost};
|
||||
case hipMemcpyDeviceToDevice:
|
||||
return {hipMemoryTypeDevice, hipMemoryTypeDevice};
|
||||
case hipMemcpyDefault:
|
||||
return {hipMemoryTypeUnified, hipMemoryTypeUnified};
|
||||
}
|
||||
|
||||
ShouldNotReachHere();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
inline
|
||||
HIP_MEMCPY3D getDrvMemcpy3DDesc(const hip_Memcpy2D& desc2D) {
|
||||
HIP_MEMCPY3D desc3D = {};
|
||||
|
||||
desc3D.srcXInBytes = desc2D.srcXInBytes;
|
||||
desc3D.srcY = desc2D.srcY;
|
||||
desc3D.srcZ = 0;
|
||||
desc3D.srcLOD = 0;
|
||||
desc3D.srcMemoryType = desc2D.srcMemoryType;
|
||||
desc3D.srcHost = desc2D.srcHost;
|
||||
desc3D.srcDevice = desc2D.srcDevice;
|
||||
desc3D.srcArray = desc2D.srcArray;
|
||||
desc3D.srcPitch = desc2D.srcPitch;
|
||||
desc3D.srcHeight = 0;
|
||||
|
||||
desc3D.dstXInBytes = desc2D.dstXInBytes;
|
||||
desc3D.dstY = desc2D.dstY;
|
||||
desc3D.dstZ = 0;
|
||||
desc3D.dstLOD = 0;
|
||||
desc3D.dstMemoryType = desc2D.dstMemoryType;
|
||||
desc3D.dstHost = desc2D.dstHost;
|
||||
desc3D.dstDevice = desc2D.dstDevice;
|
||||
desc3D.dstArray = desc2D.dstArray;
|
||||
desc3D.dstPitch = desc2D.dstPitch;
|
||||
desc3D.dstHeight = 0;
|
||||
|
||||
desc3D.WidthInBytes = desc2D.WidthInBytes;
|
||||
desc3D.Height = desc2D.Height;
|
||||
desc3D.Depth = 0;
|
||||
|
||||
return desc3D;
|
||||
}
|
||||
|
||||
inline
|
||||
HIP_MEMCPY3D getDrvMemcpy3DDesc(const hipMemcpy3DParms& desc) {
|
||||
HIP_MEMCPY3D descDrv = {};
|
||||
|
||||
descDrv.WidthInBytes = desc.extent.width;
|
||||
descDrv.Height = desc.extent.height;
|
||||
descDrv.Depth = desc.extent.depth;
|
||||
|
||||
descDrv.srcXInBytes = desc.srcPos.x;
|
||||
descDrv.srcY = desc.srcPos.y;
|
||||
descDrv.srcZ = desc.srcPos.z;
|
||||
descDrv.srcLOD = 0;
|
||||
|
||||
descDrv.dstXInBytes = desc.dstPos.x;
|
||||
descDrv.dstY = desc.dstPos.y;
|
||||
descDrv.dstZ = desc.dstPos.z;
|
||||
descDrv.dstLOD = 0;
|
||||
|
||||
if (desc.srcArray != nullptr) {
|
||||
descDrv.srcMemoryType = hipMemoryTypeArray;
|
||||
descDrv.srcArray = desc.srcArray;
|
||||
// When reffering to array memory, hipPos::x is in elements.
|
||||
descDrv.srcXInBytes *= getElementSize(desc.srcArray->Format);
|
||||
}
|
||||
|
||||
if (desc.srcPtr.ptr != nullptr) {
|
||||
descDrv.srcMemoryType = std::get<0>(hip::getMemoryType(desc.kind));
|
||||
descDrv.srcHost = desc.srcPtr.ptr;
|
||||
descDrv.srcDevice = desc.srcPtr.ptr;
|
||||
descDrv.srcPitch = desc.srcPtr.pitch;
|
||||
descDrv.srcHeight = desc.srcPtr.ysize;
|
||||
}
|
||||
|
||||
if (desc.dstArray != nullptr) {
|
||||
descDrv.dstMemoryType = hipMemoryTypeArray;
|
||||
descDrv.dstArray = desc.dstArray;
|
||||
// When reffering to array memory, hipPos::x is in elements.
|
||||
descDrv.dstXInBytes *= getElementSize(desc.dstArray->Format);
|
||||
}
|
||||
|
||||
if (desc.dstPtr.ptr != nullptr) {
|
||||
descDrv.dstMemoryType = std::get<1>(getMemoryType(desc.kind));
|
||||
descDrv.dstHost = desc.dstPtr.ptr;
|
||||
descDrv.dstDevice = desc.dstPtr.ptr;
|
||||
descDrv.dstPitch = desc.dstPtr.pitch;
|
||||
descDrv.dstHeight = desc.dstPtr.ysize;
|
||||
}
|
||||
|
||||
// If a HIP array is participating in the copy, the extent is defined in terms of that array's elements.
|
||||
if ((desc.srcArray != nullptr) && (desc.dstArray == nullptr)) {
|
||||
descDrv.WidthInBytes *= getElementSize(desc.srcArray->Format);
|
||||
} else if ((desc.srcArray == nullptr) && (desc.dstArray != nullptr)) {
|
||||
descDrv.WidthInBytes *= getElementSize(desc.dstArray->Format);
|
||||
} else if ((desc.srcArray != nullptr) && (desc.dstArray != nullptr)) {
|
||||
descDrv.WidthInBytes *= getElementSize(desc.dstArray->Format);
|
||||
}
|
||||
|
||||
return descDrv;
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceType getResourceType(const HIPresourcetype resType) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<hipResourceType>(resType);
|
||||
}
|
||||
|
||||
inline
|
||||
HIPresourcetype getResourceType(const hipResourceType resType) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<HIPresourcetype>(resType);
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceDesc getResourceDesc(const HIP_RESOURCE_DESC& resDesc) {
|
||||
hipResourceDesc desc;
|
||||
|
||||
desc.resType = getResourceType(resDesc.resType);
|
||||
switch (resDesc.resType) {
|
||||
case hipResourceTypeArray:
|
||||
desc.res.array.array = resDesc.res.array.hArray;
|
||||
break;
|
||||
case hipResourceTypeMipmappedArray:
|
||||
desc.res.mipmap.mipmap = resDesc.res.mipmap.hMipmappedArray;
|
||||
break;
|
||||
case hipResourceTypeLinear:
|
||||
desc.res.linear.devPtr = resDesc.res.linear.devPtr;
|
||||
desc.res.linear.desc = getChannelFormatDesc(resDesc.res.linear.numChannels, resDesc.res.linear.format);
|
||||
desc.res.linear.sizeInBytes = resDesc.res.linear.sizeInBytes;
|
||||
break;
|
||||
case hipResourceTypePitch2D:
|
||||
desc.res.pitch2D.devPtr = resDesc.res.pitch2D.devPtr;
|
||||
desc.res.pitch2D.desc = getChannelFormatDesc(resDesc.res.pitch2D.numChannels, resDesc.res.pitch2D.format);
|
||||
desc.res.pitch2D.width = resDesc.res.pitch2D.width;
|
||||
desc.res.pitch2D.height = resDesc.res.pitch2D.height;
|
||||
desc.res.pitch2D.pitchInBytes = resDesc.res.pitch2D.pitchInBytes;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
inline
|
||||
HIP_RESOURCE_DESC getResourceDesc(const hipResourceDesc& resDesc) {
|
||||
HIP_RESOURCE_DESC desc;
|
||||
|
||||
desc.resType = getResourceType(resDesc.resType);
|
||||
switch (resDesc.resType) {
|
||||
case HIP_RESOURCE_TYPE_ARRAY:
|
||||
desc.res.array.hArray = resDesc.res.array.array;
|
||||
break;
|
||||
case HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY:
|
||||
desc.res.mipmap.hMipmappedArray = resDesc.res.mipmap.mipmap;
|
||||
break;
|
||||
case HIP_RESOURCE_TYPE_LINEAR:
|
||||
desc.res.linear.devPtr = resDesc.res.linear.devPtr;
|
||||
desc.res.linear.numChannels = getNumChannels(resDesc.res.linear.desc);
|
||||
desc.res.linear.format = getArrayFormat(resDesc.res.linear.desc);
|
||||
desc.res.linear.sizeInBytes = resDesc.res.linear.sizeInBytes;
|
||||
break;
|
||||
case HIP_RESOURCE_TYPE_PITCH2D:
|
||||
desc.res.pitch2D.devPtr = resDesc.res.pitch2D.devPtr;
|
||||
desc.res.pitch2D.numChannels = getNumChannels(resDesc.res.pitch2D.desc);
|
||||
desc.res.pitch2D.format = getArrayFormat(resDesc.res.pitch2D.desc);
|
||||
desc.res.pitch2D.width = resDesc.res.pitch2D.width;
|
||||
desc.res.pitch2D.height = resDesc.res.pitch2D.height;
|
||||
desc.res.pitch2D.pitchInBytes = resDesc.res.pitch2D.pitchInBytes;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
inline
|
||||
hipTextureAddressMode getAddressMode(const HIPaddress_mode mode) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<hipTextureAddressMode>(mode);
|
||||
}
|
||||
|
||||
inline
|
||||
HIPaddress_mode getAddressMode(const hipTextureAddressMode mode) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<HIPaddress_mode>(mode);
|
||||
}
|
||||
|
||||
inline
|
||||
hipTextureFilterMode getFilterMode(const HIPfilter_mode mode) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<hipTextureFilterMode>(mode);
|
||||
}
|
||||
|
||||
inline
|
||||
HIPfilter_mode getFilterMode(const hipTextureFilterMode mode) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<HIPfilter_mode>(mode);
|
||||
}
|
||||
|
||||
inline
|
||||
hipTextureReadMode getReadMode(const unsigned int flags) {
|
||||
if (flags & HIP_TRSF_READ_AS_INTEGER) {
|
||||
return hipReadModeElementType;
|
||||
} else {
|
||||
return hipReadModeNormalizedFloat;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int getReadMode(const hipTextureReadMode mode) {
|
||||
if (mode == hipReadModeElementType) {
|
||||
return HIP_TRSF_READ_AS_INTEGER;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
int getsRGB(const unsigned int flags) {
|
||||
if (flags & HIP_TRSF_SRGB) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int getsRGB(const int sRGB) {
|
||||
if (sRGB == 1) {
|
||||
return HIP_TRSF_SRGB;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
int getNormalizedCoords(const unsigned int flags) {
|
||||
if (flags & HIP_TRSF_NORMALIZED_COORDINATES) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
unsigned int getNormalizedCoords(const int normalizedCoords) {
|
||||
if (normalizedCoords == 1) {
|
||||
return HIP_TRSF_NORMALIZED_COORDINATES;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
hipTextureDesc getTextureDesc(const HIP_TEXTURE_DESC& texDesc) {
|
||||
hipTextureDesc desc;
|
||||
|
||||
desc.addressMode[0] = getAddressMode(texDesc.addressMode[0]);
|
||||
desc.addressMode[1] = getAddressMode(texDesc.addressMode[1]);
|
||||
desc.addressMode[2] = getAddressMode(texDesc.addressMode[2]);
|
||||
desc.filterMode = getFilterMode(texDesc.filterMode);
|
||||
desc.readMode = getReadMode(texDesc.flags);
|
||||
desc.sRGB = getsRGB(texDesc.flags);
|
||||
std::memcpy(desc.borderColor, texDesc.borderColor, sizeof(desc.borderColor));
|
||||
desc.normalizedCoords = getNormalizedCoords(texDesc.flags);
|
||||
desc.maxAnisotropy = texDesc.maxAnisotropy;
|
||||
desc.mipmapFilterMode = getFilterMode(texDesc.mipmapFilterMode);
|
||||
desc.mipmapLevelBias = texDesc.mipmapLevelBias;
|
||||
desc.minMipmapLevelClamp = texDesc.minMipmapLevelClamp;
|
||||
desc.maxMipmapLevelClamp = texDesc.maxMipmapLevelClamp;
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
inline
|
||||
HIP_TEXTURE_DESC getTextureDesc(const hipTextureDesc& texDesc) {
|
||||
HIP_TEXTURE_DESC desc;
|
||||
|
||||
desc.addressMode[0] = getAddressMode(texDesc.addressMode[0]);
|
||||
desc.addressMode[1] = getAddressMode(texDesc.addressMode[1]);
|
||||
desc.addressMode[2] = getAddressMode(texDesc.addressMode[2]);
|
||||
desc.filterMode = getFilterMode(texDesc.filterMode);
|
||||
desc.flags = 0;
|
||||
desc.flags |= getReadMode(texDesc.readMode);
|
||||
desc.flags |= getsRGB(texDesc.sRGB);
|
||||
desc.flags |= getNormalizedCoords(texDesc.normalizedCoords);
|
||||
desc.maxAnisotropy = texDesc.maxAnisotropy;
|
||||
desc.mipmapFilterMode = getFilterMode(texDesc.mipmapFilterMode);
|
||||
desc.mipmapLevelBias = texDesc.mipmapLevelBias;
|
||||
desc.minMipmapLevelClamp = texDesc.minMipmapLevelClamp;
|
||||
desc.maxMipmapLevelClamp = texDesc.maxMipmapLevelClamp;
|
||||
std::memcpy(desc.borderColor, texDesc.borderColor, sizeof(desc.borderColor));
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceViewFormat getResourceViewFormat(const HIPresourceViewFormat format) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<hipResourceViewFormat>(format);
|
||||
}
|
||||
|
||||
inline
|
||||
HIPresourceViewFormat getResourceViewFormat(const hipResourceViewFormat format) {
|
||||
// These two enums should be isomorphic.
|
||||
return static_cast<HIPresourceViewFormat>(format);
|
||||
}
|
||||
|
||||
inline
|
||||
hipResourceViewDesc getResourceViewDesc(const HIP_RESOURCE_VIEW_DESC& resViewDesc) {
|
||||
hipResourceViewDesc desc;
|
||||
|
||||
desc.format = getResourceViewFormat(resViewDesc.format);
|
||||
desc.width = resViewDesc.width;
|
||||
desc.height = resViewDesc.height;
|
||||
desc.depth = resViewDesc.depth;
|
||||
desc.firstMipmapLevel = resViewDesc.firstMipmapLevel;
|
||||
desc.lastMipmapLevel = resViewDesc.lastMipmapLevel;
|
||||
desc.firstLayer = resViewDesc.firstLayer;
|
||||
desc.lastLayer = resViewDesc.lastLayer;
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
inline
|
||||
HIP_RESOURCE_VIEW_DESC getResourceViewDesc(const hipResourceViewDesc& resViewDesc) {
|
||||
HIP_RESOURCE_VIEW_DESC desc;
|
||||
|
||||
desc.format = getResourceViewFormat(resViewDesc.format);
|
||||
desc.width = resViewDesc.width;
|
||||
desc.height = resViewDesc.height;
|
||||
desc.depth = resViewDesc.depth;
|
||||
desc.firstMipmapLevel = resViewDesc.firstMipmapLevel;
|
||||
desc.lastMipmapLevel = resViewDesc.lastMipmapLevel;
|
||||
desc.firstLayer = resViewDesc.firstLayer;
|
||||
desc.lastLayer = resViewDesc.lastLayer;
|
||||
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
@@ -491,16 +491,34 @@ hipError_t hipSetDevice ( int device ) {
|
||||
hipError_t hipSetDeviceFlags ( unsigned int flags ) {
|
||||
HIP_INIT_API(hipSetDeviceFlags, flags);
|
||||
|
||||
/* FIXME */
|
||||
/* Not all of Ctx may be implemented */
|
||||
|
||||
unsigned supportedFlags =
|
||||
constexpr uint32_t supportedFlags =
|
||||
hipDeviceScheduleMask | hipDeviceMapHost | hipDeviceLmemResizeToMax;
|
||||
|
||||
if (flags & (~supportedFlags)) {
|
||||
if (flags & ~supportedFlags) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
amd::Device* device = hip::getCurrentDevice()->devices()[0];
|
||||
switch (flags & hipDeviceScheduleMask) {
|
||||
case hipDeviceScheduleAuto:
|
||||
// Current behavior is different from the spec, due to MT usage in runtime
|
||||
if (hip::host_device->devices().size() >= std::thread::hardware_concurrency()) {
|
||||
device->SetActiveWait(false);
|
||||
break;
|
||||
}
|
||||
// Fall through for active wait...
|
||||
case hipDeviceScheduleSpin:
|
||||
case hipDeviceScheduleYield:
|
||||
// The both options falls into yield, because MT usage in runtime
|
||||
device->SetActiveWait(true);
|
||||
break;
|
||||
case hipDeviceScheduleBlockingSync:
|
||||
device->SetActiveWait(false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
|
||||
+6
-14
@@ -25,7 +25,9 @@
|
||||
namespace hip {
|
||||
|
||||
bool Event::ready() {
|
||||
event_->notifyCmdQueue();
|
||||
if (event_->status() != CL_COMPLETE) {
|
||||
event_->notifyCmdQueue();
|
||||
}
|
||||
|
||||
return (event_->status() == CL_COMPLETE);
|
||||
}
|
||||
@@ -93,16 +95,13 @@ hipError_t Event::elapsedTime(Event& eStop, float& ms) {
|
||||
}
|
||||
|
||||
hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
|
||||
if (stream_ == hostQueue) return hipSuccess;
|
||||
if ((event_ == nullptr) || (event_->command().queue() == hostQueue)) {
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
amd::ScopedLock lock(lock_);
|
||||
bool retain = false;
|
||||
|
||||
if (event_ == nullptr) {
|
||||
event_ = stream_->getLastQueuedCommand(true);
|
||||
retain = true;
|
||||
}
|
||||
|
||||
if (!event_->notifyCmdQueue()) {
|
||||
return hipErrorLaunchOutOfResources;
|
||||
}
|
||||
@@ -116,19 +115,12 @@ hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
|
||||
command->enqueue();
|
||||
command->release();
|
||||
|
||||
if (retain) {
|
||||
event_->release();
|
||||
event_ = nullptr;
|
||||
}
|
||||
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
void Event::addMarker(amd::HostQueue* queue, amd::Command* command) {
|
||||
amd::ScopedLock lock(lock_);
|
||||
|
||||
stream_ = queue;
|
||||
|
||||
if (event_ == &command->event()) return;
|
||||
|
||||
if (event_ != nullptr) {
|
||||
|
||||
@@ -37,7 +37,10 @@ public:
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event(unsigned int flags) : flags(flags), lock_("hipEvent_t"), stream_(getNullStream()), event_(nullptr) {}
|
||||
Event(unsigned int flags) : flags(flags), lock_("hipEvent_t"), event_(nullptr) {
|
||||
// No need to init event_ here as addMarker does that
|
||||
}
|
||||
|
||||
~Event() {
|
||||
if (event_ != nullptr) {
|
||||
event_->release();
|
||||
|
||||
برخی از فایل ها نشان داده نشدند زیرا تعداد زیادی فایل در این تفاوت تغییر کرده اند نمایش بیشتر
مرجع در شماره جدید
Block a user