NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
dpa_nvqual_kernels_dev.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <stdint.h>
27 #include <stddef.h>
28 #include <dpaintrin.h>
29 #include <doca_dpa_dev.h>
31 #include "../common/dpa_nvqual_common_defs.h"
32 
44 {
45  DOCA_DPA_DEV_LOG_DBG("DPA thread kernel has been activated\n");
46 
48 
49  DOCA_DPA_DEV_LOG_DBG("%s called with src=%ld, dst=%ld, size=%ld, num_ops=%ld\n",
50  __func__,
51  tls->src_buf,
52  tls->dst_buf,
53  tls->buffers_size,
54  tls->num_ops);
55 
56  uint64_t src = tls->src_buf;
57  uint64_t dst = tls->dst_buf;
58  size_t size = tls->buffers_size;
59  uint64_t num_ops = tls->num_ops;
60  uint64_t start_cycles, end_cycles;
61 
62  start_cycles = __dpa_thread_cycles();
63  for (uint64_t op_idx = 0; op_idx < num_ops; op_idx++) {
64  for (size_t i = 0; i < size; i++) {
65  ((uint8_t *)dst)[i] = ((uint8_t *)src)[i];
66  }
67  }
68 
69  end_cycles = __dpa_thread_cycles();
70 
71  uint64_t ret_val = end_cycles - start_cycles;
72 
73  ((struct dpa_nvqual_thread_ret *)tls->thread_ret)->eu = tls->eu;
74  ((struct dpa_nvqual_thread_ret *)tls->thread_ret)->val = ret_val;
75 
77 
79 }
80 
90 __dpa_rpc__ uint64_t dpa_nvqual_entry_point(doca_dpa_dev_uintptr_t dev_notification_completions, uint64_t num_threads)
91 {
92  DOCA_DPA_DEV_LOG_DBG("DPA entry-point RPC has been called\n");
93 
94  for (uint64_t i = 0; i < num_threads; i++) {
95  doca_dpa_dev_thread_notify(((doca_dpa_dev_notification_completion_t *)dev_notification_completions)[i]);
96  }
97 
98  DOCA_DPA_DEV_LOG_DBG("DPA entry-point RPC completed\n");
99 
100  return 0;
101 }
__dpa_global__ void dpa_nvqual_kernel(void)
Kernel function of DPA nvqual thread.
__dpa_rpc__ uint64_t dpa_nvqual_entry_point(doca_dpa_dev_uintptr_t dev_notification_completions, uint64_t num_threads)
DPA nvqual entry point RPC function.
struct dpa_thread_arg __dpa_global__
static uint64_t *restrict src
Definition: dpaintrin.h:230
#define __dpa_thread_cycles()
Definition: dpaintrin.h:127
DOCA_EXPERIMENTAL void doca_dpa_dev_sync_event_update_add(doca_dpa_dev_sync_event_t dpa_dev_se_handle, uint64_t value)
Atomically increase the counter of a DOCA Sync Event by a given value.
DOCA_EXPERIMENTAL void doca_dpa_dev_thread_reschedule(void)
Reschedule a DPA thread.
#define DOCA_DPA_DEV_LOG_DBG(...)
Generate a DOCA DPA device DEBUG log message.
Definition: doca_dpa_dev.h:295
DOCA_EXPERIMENTAL void doca_dpa_dev_thread_notify(doca_dpa_dev_notification_completion_t comp_handle)
Notify the completion handle and trigger the attached thread.
DOCA_EXPERIMENTAL doca_dpa_dev_uintptr_t doca_dpa_dev_thread_get_local_storage(void)
Get DPA thread local storage.
uint64_t doca_dpa_dev_uintptr_t
DPA pointer type definition.
Definition: doca_dpa.h:78
uint64_t doca_dpa_dev_notification_completion_t
DPA notification completion handle type definition.
Definition: doca_dpa.h:98
doca_dpa_dev_uintptr_t dst_buf
doca_dpa_dev_uintptr_t src_buf
doca_dpa_dev_sync_event_t dev_se
doca_dpa_dev_uintptr_t thread_ret