2018-06-25 17:03:09 +02:00
|
|
|
/** GPU Kernels.
|
|
|
|
*
|
2023-01-07 17:20:15 +01:00
|
|
|
* Author: Daniel Krebs <github@daniel-krebs.net>
|
2023-09-08 11:35:18 +02:00
|
|
|
* SPDX-FileCopyrightText: 2017 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2023-01-07 17:20:15 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2018-06-25 17:03:09 +02:00
|
|
|
*********************************************************************************/
|
2020-06-14 22:12:41 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2018-05-15 17:35:45 +02:00
|
|
|
|
|
|
|
#include <villas/gpu.hpp>
|
|
|
|
|
2018-08-21 15:53:47 +02:00
|
|
|
#include <cuda_runtime.h>
|
2018-05-15 17:35:45 +02:00
|
|
|
#include <cuda.h>
|
|
|
|
|
2018-08-21 15:53:47 +02:00
|
|
|
#include "kernels.hpp"
|
|
|
|
|
2020-06-14 22:12:41 +02:00
|
|
|
using namespace villas::gpu;
|
2018-05-15 17:35:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
__global__ void
|
|
|
|
kernel_mailbox(volatile uint32_t *mailbox, volatile uint32_t* counter)
|
|
|
|
{
|
2024-02-29 21:47:13 +01:00
|
|
|
printf("[gpu] hello!\n");
|
|
|
|
printf("[gpu] mailbox: %p\n", mailbox);
|
2018-05-15 17:35:45 +02:00
|
|
|
|
2024-02-29 21:47:13 +01:00
|
|
|
printf("[kernel] started\n");
|
2018-05-15 17:35:45 +02:00
|
|
|
|
2024-02-29 21:47:13 +01:00
|
|
|
while (1) {
|
|
|
|
if (*mailbox == 1) {
|
|
|
|
*mailbox = 0;
|
|
|
|
printf("[gpu] counter = %d\n", *counter);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-05-15 17:35:45 +02:00
|
|
|
|
2024-02-29 21:47:13 +01:00
|
|
|
printf("[gpu] quit\n");
|
2018-05-15 17:35:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__global__ void
|
|
|
|
kernel_memcpy(volatile uint8_t* dst, volatile uint8_t* src, size_t length)
|
|
|
|
{
|
2024-02-29 21:47:13 +01:00
|
|
|
while (length > 0) {
|
|
|
|
*dst++ = *src++;
|
|
|
|
length--;
|
|
|
|
}
|
2018-05-15 17:35:45 +02:00
|
|
|
}
|