Код: Выделить всё
#include "cmdparser.hpp"
#include "example_utils.hpp"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define BLOCK_SIZE 16
#define N 5
__global__ void rritz( float*v , int n) {
//int fila = blockIdx.y*blockDim.y + threadIdx.y;
int fila = blockIdx.y*blockDim.y + threadIdx.y;
// std::vector v(n);
const float h = 1 / n;
const float q = 4;
if(fila < n) {
// int auxi = fila;
v[fila] = q;
}
}
int main(){
std::vector h_v(N);
float *d_v;
hipMalloc(&d_v, sizeof(float)*N);
dim3 threadsPerBlock (BLOCK_SIZE, BLOCK_SIZE);
int bloques = ceil(N/BLOCK_SIZE);
dim3 blocksPerGrid (bloques, bloques);
rritz(d_v, N);
hipDeviceSynchronize();
hipMemcpy(h_v.data(), d_v, sizeof(float)*N, hipMemcpyDeviceToHost);
for(auto i:h_v)
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79692208/rocms-memory-copy-function-not-working-at-expected-host-function-returning-vec[/url]