1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-23 00:00:01 +01:00
VILLASnode/fpga/lib/gpu/kernels.cu
Daniel Krebs 13fd3f3c2a gpu: implement basic GPU plugin that can do DMA to and from its memory
Using CUDA, memory can be allocated on the GPU and shared to peers on
the PCIe bus such as the FPGA. Furthermore, the DMA on the GPU can also
be used to read and write to/from other memory on the PCIe bus, such as
BRAM on the FPGA.
2018-05-15 18:15:17 +02:00

42 lines
677 B
Text

#include <stdio.h>
#include <villas/gpu.hpp>
#include "kernels.hpp"
#include "cuda_runtime.h"
#include <cuda.h>
namespace villas {
namespace gpu {
__global__ void
kernel_mailbox(volatile uint32_t *mailbox, volatile uint32_t* counter)
{
printf("[gpu] hello!\n");
printf("[gpu] mailbox: %p\n", mailbox);
printf("[kernel] started\n");
while(1) {
if (*mailbox == 1) {
*mailbox = 0;
printf("[gpu] counter = %d\n", *counter);
break;
}
}
printf("[gpu] quit\n");
}
__global__ void
kernel_memcpy(volatile uint8_t* dst, volatile uint8_t* src, size_t length)
{
while(length > 0) {
*dst++ = *src++;
length--;
}
}
} // namespace villas
} // namespace gpu