Updatepackage/minigmg (#26467)

* MiniGMG, add support for optimised flags + SIMDe implementation of AVX instrinsics

* Add .gitlab-ci.yml

* NVHPC fast

* remove CI

* Syntax fix
This commit is contained in:
Oliver Perks 2021-10-07 20:49:14 +01:00 committed by GitHub
parent 0b9914e2f5
commit da31c7e894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 5 deletions

View File

@ -0,0 +1,21 @@
diff --git a/timer.aarch64.c b/timer.aarch64.c
new file mode 100644
index 0000000..ca47633
--- /dev/null
+++ b/timer.aarch64.c
@@ -0,0 +1,15 @@
+//------------------------------------------------------------------------------------------------------------------------------
+// Samuel Williams
+// SWWilliams@lbl.gov
+// Lawrence Berkeley National Lab
+//------------------------------------------------------------------------------------------------------------------------------
+#include <stdint.h>
+
+
+uint64_t CycleTime(){
+ uint64_t val;
+ asm volatile("mrs %0, cntvct_el0" : "=r" (val));
+
+ return val;
+}
+

View File

@ -0,0 +1,14 @@
diff --git a/operators.ompif/exchange_boundary.c b/operators.ompif/exchange_boundary.c
index 6cb27b2..702a2cb 100644
--- a/operators.ompif/exchange_boundary.c
+++ b/operators.ompif/exchange_boundary.c
@@ -6,7 +6,7 @@
#include <stdint.h>
#include "../timer.h"
//------------------------------------------------------------------------------------------------------------------------------
-inline void DoBufferCopy(domain_type *domain, int level, int grid_id, int buffer){
+inline static void DoBufferCopy(domain_type *domain, int level, int grid_id, int buffer){
// copy 3D array from read_i,j,k of read[] to write_i,j,k in write[]
int dim_i = domain->bufferCopies[level][buffer].dim.i;
int dim_j = domain->bufferCopies[level][buffer].dim.j;

View File

@ -24,17 +24,73 @@ class Minigmg(Package):
version('master', sha256='1c2d27496a881f655f5e849d6a7a132625e535739f82575991c511cc2cf899ac')
variant('vec', default='ompif', description='Which method of vectorisation to use',
values=('ompif', 'sse', 'avx', 'simde'), multi=False)
variant('opt', default=False, description='Enable optimization flags for improved OpenMP')
depends_on('mpi')
# Set up SIMD Everywhere config
depends_on('simde', when='vec=simde')
patch('simde.patch', when='vec=simde')
# Patch to add timer for Aarch64 rather than rdtsc
patch('aarch64_time.patch', when='target=aarch64:')
# Replaces inline with inline static, for correct syntax
patch('inline_static.patch')
phases = ['build', 'install']
def build(self, spec, prefix):
cc = Executable(spec['mpi'].mpicc)
cc('-O3', self.compiler.openmp_flag, 'miniGMG.c',
'mg.c', 'box.c', 'solver.c', 'operators.ompif.c', 'timer.x86.c',
'-D__MPI', '-D__COLLABORATIVE_THREADING=6',
'-D__TEST_MG_CONVERGENCE', '-D__PRINT_NORM', '-D__USE_BICGSTAB',
'-o', 'run.miniGMG', '-lm')
args = []
# Default optimisation level
if spec.satisfies('+opt'):
if self.spec.satisfies('%nvhpc'):
args.append('-fast')
else:
args.append('-Ofast')
else:
args.append('-O3')
# Add OpenMP flag
args += [self.compiler.openmp_flag]
args += ['miniGMG.c', 'mg.c', 'box.c', 'solver.c']
# Set the correct operators file - using the vec variant
if spec.satisfies('vec=sse'):
args += ['operators.sse.c']
elif spec.satisfies('vec=avx'):
args += ['operators.avx.c']
elif spec.satisfies('vec=simde'):
args += ['operators.simde.c']
else:
args += ['operators.ompif.c']
# Switch out timer file (depends on patch)
if spec.satisfies('target=aarch64:'):
args += ['timer.aarch64.c']
else:
args += ['timer.x86.c']
args += ['-D__MPI']
if spec.satisfies('+opt'):
args += ['-D__PREFETCH_NEXT_PLANE_FROM_DRAM']
args += ['-D__FUSION_RESIDUAL_RESTRICTION']
else:
args += ['-D__COLLABORATIVE_THREADING=6']
args += ['-D__TEST_MG_CONVERGENCE', '-D__PRINT_NORM', '-D__USE_BICGSTAB']
args += ['-o', 'run.miniGMG', '-lm']
cc(*args)
def install(self, spec, prefix):
mkdir(prefix.bin)

View File

@ -0,0 +1,40 @@
diff --git a/operators.simde.c b/operators.simde.c
new file mode 100755
index 0000000..22ab6fd
--- /dev/null
+++ b/operators.simde.c
@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------------------------------------------------------
+// Samuel Williams
+// SWWilliams@lbl.gov
+// Lawrence Berkeley National Lab
+//------------------------------------------------------------------------------------------------------------------------------
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <math.h>
+// #include <immintrin.h>
+#define SIMDE_ENABLE_NATIVE_ALIASES
+#define SIMDE_X86_SSE_ENABLE_NATIVE_ALIASES
+#define _MM_HINT_T0 1
+#define _MM_HINT_T1 2
+#include "simde/x86/avx2.h"
+//------------------------------------------------------------------------------------------------------------------------------
+#include "timer.h"
+#include "defines.h"
+#include "box.h"
+#include "mg.h"
+#include "operators.h"
+//------------------------------------------------------------------------------------------------------------------------------
+#include "operators.ompif/exchange_boundary.c"
+#include "operators.ompif/lambda.c"
+#include "operators.avx/gsrb.c"
+#include "operators.ompif/apply_op.c"
+#include "operators.ompif/residual.c"
+#include "operators.ompif/restriction.c"
+#include "operators.ompif/interpolation.c"
+#include "operators.ompif/misc.c"
+#include "operators.ompif/matmul.c"
+#include "operators.ompif/problem1.c"
+//------------------------------------------------------------------------------------------------------------------------------