(git:27c966b)
Loading...
Searching...
No Matches
dbm_multiply_opencl.c
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* CP2K: A general program to perform molecular dynamics simulations */
3/* Copyright 2000-2026 CP2K developers group <https://cp2k.org> */
4/* */
5/* SPDX-License-Identifier: BSD-3-Clause */
6/*----------------------------------------------------------------------------*/
8#if defined(__OFFLOAD_OPENCL) && !defined(__NO_OFFLOAD_DBM)
9
11
12/* OpenCL backend is maintained in LIBXSTREAM (samples/dbm) */
13#include <dbm_opencl.h>
14
15_Static_assert(sizeof(dbm_task_t) == DBM_OPENCL_TASK_SIZE * sizeof(int),
16 "dbm_task_t must match the native task format of LIBXSTREAM");
17
18void dbm_multiply_gpu_launch_kernel(offloadStream_t stream, double alpha,
19 const dbm_batch_t *batch,
20 const dbm_task_t *tasks,
21 const double *pack_a_data,
22 const double *pack_b_data,
23 double *shard_c_data) {
24 // Fill of a kernel padded to the maxima in percent, 100 if homogeneous.
25 const int64_t padded =
26 2LL * batch->ntasks * batch->max_m * batch->max_n * batch->max_k;
27 const int shape_info[] = {batch->max_m, batch->max_n, batch->max_k,
28 (int)(100 * batch->flops / padded)};
29 const int result = dbm_multiply_opencl_launch_kernel(
30 stream, alpha, batch->ntasks, 0 /*param_format*/, shape_info,
31 &batch->tasks->m, &tasks->m, pack_a_data, pack_b_data, shard_c_data);
32 OFFLOAD_CHECK(result);
33}
34
35int dbm_multiply_gpu_task_order(void) {
36 return dbm_multiply_opencl_task_order();
37}
38
39#endif /* defined(__OFFLOAD_OPENCL) && !defined(__NO_OFFLOAD_DBM) */
40
41/* EOF */
Internal struct for storing a batch of tasks along with its shape, which is tracked while the batch i...
int64_t flops
dbm_task_t * tasks
Internal struct for storing a task, ie. a single block multiplication.