#include <sycl/sycl.hpp>
#include <sycl/sycl.hpp>
#define TILE 16
void transpose(const float* in, float* out, int width, int height) {
__shared__ float tile[TILE][TILE];
int x = item.get_group(0) * item.get_local_range() + item.get_local_id();
int y = item.get_group(0) * item.get_local_range() + item.get_local_id();
if (x < width && y < height) {
tile[item.get_local_id()][item.get_local_id()] = in[y * width + x];
}
item.barrier(sycl::access::fence_space::global_space);
int ox = item.get_group(0) * item.get_local_range() + item.get_local_id();
int oy = item.get_group(0) * item.get_local_range() + item.get_local_id();
if (ox < height && oy < width) {
out[oy * height + ox] = tile[item.get_local_id()][item.get_local_id()];
}
}
int main(void) {
const int W = 1024;
const int H = 1024;
float* d_in = nullptr;
float* d_out = nullptr;
cudaMalloc((void**)&d_in, W * H * sizeof(float));
cudaMalloc((void**)&d_out, W * H * sizeof(float));
cudaMemcpy(d_in, d_in, W * H * sizeof(float), cudaMemcpyDeviceToDevice);
dim3 grid(W / TILE, H / TILE);
dim3 block(TILE, TILE);
{ }); }); smem=none stream=default args=d_in, d_out, W, H };
cudaDeviceSynchronize();
cudaFree(d_in);
cudaFree(d_out);
return 0;
}