/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/docs-6.2.0/include/rpp.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/docs-6.2.0/include/rpp.h Source File#

RPP: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/docs-6.2.0/include/rpp.h Source File
rpp.h
Go to the documentation of this file.
1 /*
2 MIT License
3 
4 Copyright (c) 2019 - 2024 Advanced Micro Devices, Inc.
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
25 #ifndef RPP_H
26 #define RPP_H
27 
34 #include <export.h>
35 
36 #if RPP_BACKEND_OPENCL
37 
38 #define CL_TARGET_OPENCL_VERSION 220
39 #if defined(__APPLE__) || defined(__MACOSX)
40 #include <OpenCL/cl.h>
41 #else
42 #include <CL/cl.h>
43 #endif
45 typedef cl_command_queue rppAcceleratorQueue_t;
46 
47 #elif RPP_BACKEND_HIP
48 
49 #include <hip/hip_runtime_api.h>
51 typedef hipStream_t rppAcceleratorQueue_t;
52 
53 #endif
54 
58 #define RPP_DECLARE_OBJECT(name) \
59  struct name \
60  { \
61  }; \
62  typedef struct name* name##_t;
63 
67 RPP_DECLARE_OBJECT(rppHandle); // Create the rppHandle_t type
68 
72 typedef rppHandle_t RppHandle_t; // Create typedef for RppHandle_t
73 
74 #if _WIN32
75 #define SHARED_PUBLIC __declspec(dllexport)
76 #else
77 #define SHARED_PUBLIC __attribute__ ((visibility ("default")))
78 #endif
79 
80 #include "rppdefs.h"
81 #include "rppi.h"
82 #include "rppt.h"
83 #include "rpp_version.h"
84 
91 typedef void* (*rppAllocatorFunction)(void* context, size_t sizeBytes);
92 
99 typedef void (*rppDeallocatorFunction)(void* context, void* memory);
100 
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104 
112 extern "C" SHARED_PUBLIC const char* rppGetErrorString(rppStatus_t error);
113 
130 extern "C" SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t* handle);
131 
149 extern "C" SHARED_PUBLIC rppStatus_t rppCreateWithBatchSize(rppHandle_t* handle, size_t nBatchSize, Rpp32u numThreads = 0);
150 
166 extern "C" SHARED_PUBLIC rppStatus_t rppDestroy(rppHandle_t handle);
167 
184 extern "C" SHARED_PUBLIC rppStatus_t rppDestroyHost(rppHandle_t handle);
185 
202 extern "C" SHARED_PUBLIC rppStatus_t rppSetBatchSize(rppHandle_t handle, size_t batchSize);
203 
220 extern "C" SHARED_PUBLIC rppStatus_t rppGetBatchSize(rppHandle_t handle, size_t *batchSize);
221 
222 #if GPU_SUPPORT
223 
241 extern "C" SHARED_PUBLIC rppStatus_t rppCreateWithStream(rppHandle_t* handle, rppAcceleratorQueue_t stream);
242 
260 extern "C" SHARED_PUBLIC rppStatus_t rppCreateWithStreamAndBatchSize(rppHandle_t* handle, rppAcceleratorQueue_t stream, size_t nBatchSize);
261 
277 extern "C" SHARED_PUBLIC rppStatus_t rppDestroyGPU(rppHandle_t handle);
278 
295 extern "C" SHARED_PUBLIC rppStatus_t rppSetStream(rppHandle_t handle, rppAcceleratorQueue_t streamID);
296 
313 extern "C" SHARED_PUBLIC rppStatus_t rppGetStream(rppHandle_t handle, rppAcceleratorQueue_t* streamID);
314 
333 extern "C" SHARED_PUBLIC rppStatus_t rppSetAllocator(rppHandle_t handle, rppAllocatorFunction allocator, rppDeallocatorFunction deallocator, void* allocatorContext);
334 
351 extern "C" SHARED_PUBLIC rppStatus_t rppGetKernelTime(rppHandle_t handle, float* time);
352 
369 extern "C" SHARED_PUBLIC rppStatus_t rppEnableProfiling(rppHandle_t handle, bool enable);
370 
371 #endif // GPU_SUPPORT
372 
373 #ifdef __cplusplus
374 }
375 #endif // __cplusplus
376 
377 #endif // RPP_H
#define RPP_DECLARE_OBJECT(name)
Construct type name from a struct.
Definition: rpp.h:58
SHARED_PUBLIC rppStatus_t rppSetBatchSize(rppHandle_t handle, size_t batchSize)
Set batch size given a RPP handle.
SHARED_PUBLIC rppStatus_t rppSetAllocator(rppHandle_t handle, rppAllocatorFunction allocator, rppDeallocatorFunction deallocator, void *allocatorContext)
Set allocator given a RPP handle.
hipStream_t rppAcceleratorQueue_t
Set rppAcceleratorQueue_t to hipStream_t if RPP_BACKEND_HIP.
Definition: rpp.h:51
SHARED_PUBLIC rppStatus_t rppDestroyHost(rppHandle_t handle)
Destory RPP HOST handle - To be deprecated.
void(* rppDeallocatorFunction)(void *context, void *memory)
Handles RPP context allocations.
Definition: rpp.h:99
SHARED_PUBLIC rppStatus_t rppDestroyGPU(rppHandle_t handle)
Destory RPP GPU handle.
SHARED_PUBLIC rppStatus_t rppGetKernelTime(rppHandle_t handle, float *time)
Get time taken by previous kernel.
SHARED_PUBLIC rppStatus_t rppCreateWithStreamAndBatchSize(rppHandle_t *handle, rppAcceleratorQueue_t stream, size_t nBatchSize)
Creates RPP handle with accelerator stream for GPU batch processing.
SHARED_PUBLIC rppStatus_t rppCreateWithBatchSize(rppHandle_t *handle, size_t nBatchSize, Rpp32u numThreads=0)
Creates RPP handle for HOST batch processing.
void *(* rppAllocatorFunction)(void *context, size_t sizeBytes)
Handles RPP context allocations.
Definition: rpp.h:91
SHARED_PUBLIC rppStatus_t rppDestroy(rppHandle_t handle)
Destory RPP handle.
SHARED_PUBLIC rppStatus_t rppSetStream(rppHandle_t handle, rppAcceleratorQueue_t streamID)
Set accelerator stream given a RPP handle.
SHARED_PUBLIC rppStatus_t rppGetStream(rppHandle_t handle, rppAcceleratorQueue_t *streamID)
Get accelerator stream given a RPP handle.
rppHandle_t RppHandle_t
RPP handle.
Definition: rpp.h:72
SHARED_PUBLIC rppStatus_t rppCreateWithStream(rppHandle_t *handle, rppAcceleratorQueue_t stream)
Creates RPP handle with accelerator stream for GPU single image processing - To be deprecated.
SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t *handle)
Creates RPP handle for HOST single image processing - To be deprecated.
SHARED_PUBLIC const char * rppGetErrorString(rppStatus_t error)
Returns error string.
SHARED_PUBLIC rppStatus_t rppGetBatchSize(rppHandle_t handle, size_t *batchSize)
Get batch size given a RPP Handle.
SHARED_PUBLIC rppStatus_t rppEnableProfiling(rppHandle_t handle, bool enable)
Enable Profiling.
unsigned int Rpp32u
32 bit unsigned int
Definition: rppdefs.h:80
rppStatus_t
RPP rppStatus_t type enums.
Definition: rppdefs.h:155
ROCm Performance Primitives (RPP) version.
RPP common HOST/GPU typedef, enum and structure definitions.
RPP Image Operations - To be deprecated.
RPP Tensor Operations.