1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2010-2022, 2024 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
*
* StarPU is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
*
* StarPU is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
*/
#include <starpu.h>
#include "../helper.h"
#include "increment.h"
#ifdef STARPU_USE_CUDA
extern void increment_cuda(void *descr[], void *_args);
extern void redux_cuda(void *descr[], void *arg);
extern void neutral_cuda(void *descr[], void *arg);
#endif
#ifdef STARPU_USE_HIP
extern void increment_hip(void *descr[], void *_args);
extern void redux_hip(void *descr[], void *arg);
extern void neutral_hip(void *descr[], void *arg);
#endif
#ifdef STARPU_USE_OPENCL
extern void increment_opencl(void *buffers[], void *args);
extern void redux_opencl(void *descr[], void *arg);
extern void neutral_opencl(void *descr[], void *arg);
#endif
void increment_cpu(void *descr[], void *arg)
{
(void)arg;
unsigned *tokenptr = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
(*tokenptr)++;
}
struct starpu_codelet increment_cl =
{
.modes = {STARPU_RW},
.cpu_funcs = {increment_cpu},
#ifdef STARPU_USE_CUDA
.cuda_funcs = {increment_cuda},
.cuda_flags = {STARPU_CUDA_ASYNC},
#endif
#ifdef STARPU_USE_HIP
.hip_funcs = {increment_hip},
.hip_flags = {STARPU_HIP_ASYNC},
#endif
#ifdef STARPU_USE_OPENCL
.opencl_funcs = {increment_opencl},
.opencl_flags = {STARPU_OPENCL_ASYNC},
#endif
.cpu_funcs_name = {"increment_cpu"},
.nbuffers = 1,
.flags = STARPU_CODELET_SIMGRID_EXECUTE,
};
struct starpu_codelet increment_redux_cl =
{
.modes = {STARPU_REDUX},
.cpu_funcs = {increment_cpu},
#ifdef STARPU_USE_CUDA
.cuda_funcs = {increment_cuda},
.cuda_flags = {STARPU_CUDA_ASYNC},
#endif
#ifdef STARPU_USE_HIP
.hip_funcs = {increment_hip},
.hip_flags = {STARPU_HIP_ASYNC},
#endif
#ifdef STARPU_USE_OPENCL
.opencl_funcs = {increment_opencl},
.opencl_flags = {STARPU_OPENCL_ASYNC},
#endif
.cpu_funcs_name = {"increment_cpu"},
.nbuffers = 1,
.flags = STARPU_CODELET_SIMGRID_EXECUTE,
};
void redux_cpu(void *descr[], void *arg)
{
(void)arg;
unsigned *dst = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
unsigned *src = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[1]);
*dst = *dst + *src;
}
struct starpu_codelet redux_cl =
{
.modes = {STARPU_RW|STARPU_COMMUTE, STARPU_R},
.nbuffers = 2,
#ifdef STARPU_USE_CUDA
.cuda_funcs = {redux_cuda},
.cuda_flags = {STARPU_CUDA_ASYNC},
#endif
#ifdef STARPU_USE_HIP
.hip_funcs = {redux_hip},
.hip_flags = {STARPU_HIP_ASYNC},
#endif
#ifdef STARPU_USE_OPENCL
.opencl_funcs = {redux_opencl},
.opencl_flags = {STARPU_OPENCL_ASYNC},
#endif
.cpu_funcs = {redux_cpu},
.cpu_funcs_name = {"redux_cpu"},
.flags = STARPU_CODELET_SIMGRID_EXECUTE,
};
void neutral_cpu(void *descr[], void *arg)
{
(void)arg;
unsigned *dst = (unsigned *)STARPU_VARIABLE_GET_PTR(descr[0]);
*dst = 0;
}
struct starpu_codelet neutral_cl =
{
#ifdef STARPU_USE_CUDA
.cuda_funcs = {neutral_cuda},
.cuda_flags = {STARPU_CUDA_ASYNC},
#endif
#ifdef STARPU_USE_HIP
.hip_funcs = {neutral_hip},
.hip_flags = {STARPU_HIP_ASYNC},
#endif
#ifdef STARPU_USE_OPENCL
.opencl_funcs = {neutral_opencl},
.opencl_flags = {STARPU_OPENCL_ASYNC},
#endif
.cpu_funcs = {neutral_cpu},
.cpu_funcs_name = {"neutral_cpu"},
.modes = {STARPU_W},
.nbuffers = 1,
.flags = STARPU_CODELET_SIMGRID_EXECUTE,
};
#ifndef STARPU_USE_OPENCL
void increment_load_opencl()
{
}
void increment_unload_opencl()
{
}
#endif
|