#include <iostream>
#include <cuda_runtime.h>
__global__ void generateHexString(char* result, int* array)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
result[idx] = array[idx];
}
int main()
{
const int arraySize = 16;
char array[arraySize] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
char result[arraySize];
char* d_result;
int* d_array;
cudaMalloc((void**)&d_result, arraySize * sizeof(char));
cudaMalloc((void**)&d_array, arraySize * sizeof(int));
cudaMemcpy(d_array, array, arraySize * sizeof(int), cudaMemcpyHostToDevice);
int threadsPerBlock = 16;
int blocksPerGrid = 1;
generateHexString<<<blocksPerGrid, threadsPerBlock>>>(d_result, d_array);
cudaMemcpy(result, d_result, arraySize * sizeof(char), cudaMemcpyDeviceToHost);
cudaFree(d_result);
cudaFree(d_array);
std::cout << "Generated hex string: " << result << std::endl;
return 0;
}