Files
rocm-systems/samples/code_object_isa_decode/transpose_kernels.hpp
T
Giovanni Lenzi Baraldi 69b8a43dc6 Gbaraldi/threadtrace2 (#724)
* Added first ATT API

* Finalizing thread trace API

* Fixing more rebase conflicts

* Added codeobj disassembly sample

* Fixing merge issues with rebase [2]

* Adding ATT packets

* Implemented thread trace intercept

* Moved codeobj parser to same repo as rocprofiler

* Moved thread trace to new API

* Fixing merge conflicts

* Fixing more merge conflicts

* Adding thread trace packet reuse

* Merged aql_profile_v2 headers

* Linked ATT sample to aqlprofile

* Updated decoder to include non-loaded codeobjs

* Implemented ISA decoder into ATT sample

* Added marker_id to vaddr

* Updating aql_profile_v2 API to memcpy

* Updating thread trace API to include 64bit markers. Using the result of ISA matching.

* Added instruction type and cycles summary

* Updated sample with selection of kernel by kernel_object

* Added option to copy from memory kernels

* Moved tool_data in thread_trace to dynamic alloc

* Restoring hsa.cpp

* Fixed ATT sample crash. General improvements.

* Moved codeobj library to outside src/

* Updated license header

* Moved codeobj_capture to camelcase

* Solving some more merge conflicts

* Update samples/advanced_thread_trace/CMakeLists.txt

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update samples/advanced_thread_trace/CMakeLists.txt

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update samples/code_object_isa_decode/CMakeLists.txt

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update source/lib/rocprofiler-sdk/thread_trace/CMakeLists.txt

* Removing unused parameter check

* Adding const to isEmpty

* Removing unused warning

* Adding libdw-dev to requirements

* Running clang-format

* Commenting out new aql calls

* Clang format

* Unused variable fix

* Adding codeobj-decoder coverage

* Commenting out threadtrace

* Update samples/CMakeLists.txt

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* P

* WOverloaded

* Addressing clang-tidy

* Virtual destructor on ttracer class

* Corr id

* Fixing code source format

* Update CMakeLists.txt

* Build fixes

* Update source/lib/rocprofiler-sdk-codeobj/code_object_track.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Fix shadowing

* Update CMakeLists.txt

* Update samples/CMakeLists.txt

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ammar ELWazir <ammar.elwazir@amd.com>
Co-authored-by: Ammar ELWazir <aelwazir@amd.com>
Co-authored-by: Benjamin Welton <bewelton@amd.com>
2024-04-08 12:43:02 -07:00

85 wiersze
3.4 KiB
C++

#pragma once
#include "hip/hip_runtime.h"
#define HIP_API_CALL(CALL) \
{ \
hipError_t error_ = (CALL); \
if(error_ != hipSuccess) \
{ \
lock_guard_t _hip_api_print_lk{print_lock}; \
fprintf(stderr, \
"%s:%d :: HIP error : %s\n", \
__FILE__, \
__LINE__, \
hipGetErrorString(error_)); \
exit(EXIT_FAILURE); \
} \
}
#define TILE_DIM 64
template <typename T>
__global__ void
transposeNaive(T* odata, const T* idata, size_t size)
{
size_t idx = blockIdx.x * TILE_DIM + threadIdx.x;
size_t block_posy = blockIdx.y * TILE_DIM;
for(size_t idy = threadIdx.y; idy < TILE_DIM; idy += blockDim.y)
odata[size * idx + block_posy + idy] = idata[idx + (block_posy + idy) * size];
}
template <typename T>
__global__ void
transposeLdsNoBankConflicts(T* odata, const T* idata, size_t size)
{
__shared__ T tile[TILE_DIM][TILE_DIM + 1];
size_t idx_in = blockIdx.x * TILE_DIM + threadIdx.x;
size_t idy_in = blockIdx.y * TILE_DIM + threadIdx.y;
size_t index_in = idx_in + idy_in * size;
size_t idx_out = blockIdx.y * TILE_DIM + threadIdx.x;
size_t idy_out = blockIdx.x * TILE_DIM + threadIdx.y;
size_t index_out = idx_out + idy_out * size;
for(size_t y = 0; y < TILE_DIM; y += blockDim.y)
tile[threadIdx.y + y][threadIdx.x] = idata[index_in + y * size];
__syncthreads();
for(size_t y = 0; y < TILE_DIM; y += blockDim.y)
odata[index_out + y * size] = tile[threadIdx.x][threadIdx.y + y];
}
// Generates more interesting ISA
template <typename T>
__global__ void
transposeLdsSwapInplace(T* odata, const T* idata, size_t size)
{
__shared__ T tile[TILE_DIM][TILE_DIM];
const size_t idx_in = blockIdx.x * TILE_DIM + threadIdx.x;
for(size_t idy = threadIdx.y; idy < TILE_DIM; idy += blockDim.y)
tile[idy][threadIdx.x] = idata[idx_in + (idy + blockIdx.y * TILE_DIM) * size];
__syncthreads();
for(size_t idy = threadIdx.y; idy < TILE_DIM; idy += blockDim.y)
if(idy < threadIdx.x)
{
T temp = tile[idy][threadIdx.x];
tile[idy][threadIdx.x] = tile[threadIdx.x][idy];
tile[threadIdx.x][idy] = temp;
}
__syncthreads();
const size_t idx_out = blockIdx.y * TILE_DIM + threadIdx.x;
for(size_t idy = threadIdx.y; idy < TILE_DIM; idy += blockDim.y)
odata[(blockIdx.x * TILE_DIM + idy) * size + idx_out] = tile[idy][threadIdx.x];
}