NewMadeleine

Documentation

« back to PM2 home.
nm_gpu.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2006-2026 (see AUTHORS file)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef NM_GPU_H
17#define NM_GPU_H
18
24#include "nm_private_config.h"
25
26#ifdef NMAD_CUDA
27#include <cuda.h>
28#include <cuda_runtime.h>
29#include <cuda_runtime_api.h>
30#endif /* NMAD_CUDA */
31
32#ifdef NMAD_HIP
33#include <hip/hip_runtime.h>
34#include <hip/hip_runtime_api.h>
35#endif /* NMAD_HIP */
36
37
38/* ** GPU frontend for nm_data ***************************** */
39
40static inline int nm_data_is_gpu(const struct nm_data_properties_s*p_props)
41{
42#ifdef NMAD_CUDA
43 return p_props->is_cuda;
44#elif defined(NMAD_HIP)
45 return p_props->is_hip;
46#endif /* NMAD_HIP */
47 return 0;
48}
49
50
52void nm_data_memcpy(void*p_ptr_dest, const void*p_ptr_from, const nm_len_t len);
53
54
55/* ** GPU frontend for pw ********************************** */
56
59static inline void nm_pw_gpu_fill(struct nm_pkt_wrap_s*p_pw, const struct nm_data_properties_s*p_props)
60{
61#ifdef NMAD_CUDA
62 if(p_props->is_cuda)
63 {
65 }
66#endif /* NMAD_CUDA */
67#ifdef NMAD_HIP
68 if(p_props->is_hip)
69 {
70 p_pw->flags |= NM_PW_DATA_IS_HIP;
71 }
72#endif /* NMAD_CUDA */
73}
74
75
76#endif /* NM_GPU_H */
static int nm_data_is_gpu(const struct nm_data_properties_s *p_props)
Definition nm_gpu.h:40
static void nm_pw_gpu_fill(struct nm_pkt_wrap_s *p_pw, const struct nm_data_properties_s *p_props)
fill the GPU flags of a pw.
Definition nm_gpu.h:59
void nm_data_memcpy(void *p_ptr_dest, const void *p_ptr_from, const nm_len_t len)
memcpy without knowing whether memory is on GPU or not; assume unified addressing
uint16_t len
chunk len
Definition nm_headers.h:0
#define NM_PW_DATA_IS_HIP
data in v is on a HIP / ROCm GPU
#define NM_PW_DATA_IS_CUDA
data in v is on a CUDA GPU
uint64_t nm_len_t
data length used by nmad
Definition nm_types.h:68
block of static properties for a given data descriptor
Definition nm_data.h:93
Internal packet wrapper.
nm_pw_flag_t flags
packet flags.