Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_mpi_reduce.c
Go to the documentation of this file.
1/*
2 Copyright (c) 2022-2024, The Neko Authors
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11
12 * Redistributions in binary form must reproduce the above
13 copyright notice, this list of conditions and the following
14 disclaimer in the documentation and/or other materials provided
15 with the distribution.
16
17 * Neither the name of the authors nor the names of its
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33*/
34
39#include <stdlib.h>
40#include <stdio.h>
41#include <mpi.h>
42#include <comm/comm.h>
43
44#include "device_mpi_op.h"
45
46void device_mpi_allreduce(void *buf_d, void *buf, int count, int nbytes, int op) {
47
48 if (nbytes == sizeof(float)) {
49 if (op == DEVICE_MPI_SUM)
51 else if (op == DEVICE_MPI_MAX)
53 else {
54 fprintf(stderr, __FILE__ ": Invalid reduction op)\n");
55 exit(1);
56 }
57 }
58 else if (nbytes == sizeof(double)) {
59 if (op == DEVICE_MPI_SUM)
61 else if (op == DEVICE_MPI_MAX)
63 else {
64 fprintf(stderr, __FILE__ ": Invalid reduction op)\n");
65 exit(1);
66 }
67 }
68 else {
69 fprintf(stderr, __FILE__ ": Invalid data type)\n");
70 exit(1);
71 }
72}
73
74void device_mpi_allreduce_inplace(void *buf_d, int count, int nbytes, int op) {
75
76 if (nbytes == sizeof(float)) {
77 if (op == DEVICE_MPI_SUM)
80 else if (op == DEVICE_MPI_MAX)
83 else {
84 fprintf(stderr, __FILE__ ": Invalid reduction op)\n");
85 exit(1);
86 }
87 }
88 else if (nbytes == sizeof(double)) {
89 if (op == DEVICE_MPI_SUM)
92 else if (op == DEVICE_MPI_MAX)
95 }
96 else {
97 fprintf(stderr, __FILE__ ": Invalid data type)\n");
98 exit(1);
99 }
100}
101
MPI_Comm NEKO_COMM
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
#define DEVICE_MPI_MAX
#define DEVICE_MPI_SUM
void device_mpi_allreduce(void *buf_d, void *buf, int count, int nbytes, int op)
void device_mpi_allreduce_inplace(void *buf_d, int count, int nbytes, int op)
real * buf
Definition pipecg_aux.cu:42