Skip to content

Commit

Permalink
fix HPC build, documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Gordon committed Jun 25, 2023
1 parent 10c4e42 commit 06edef5
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: meson setup build
- name: configure
working-directory: ./core/source/build
run: meson configure -Domp=true -Docl=false
run: meson configure -Domp=true -Docl=false -Dhpc=false
- name: build
working-directory: ./core/source/build
run: meson compile
Expand Down
23 changes: 23 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@
"intelliSenseMode": "macos-clang-x64",
"configurationProvider": "mesonbuild.mesonbuild"
},
{
"name": "BrewGCC-ARM",
"includePath": [
"${workspaceFolder}/core/source/**"
],
"defines": ["USE_DESKTOP","USE_OPENMP","VBITS=128"],
"compilerArgs": [
"-I${workspaceFolder}/core/source/base",
"-I${workspaceFolder}/core/source/concurrency",
"-I${workspaceFolder}/core/source/io",
"-I${workspaceFolder}/core/source/particles",
"-I${workspaceFolder}/core/source/solver",
"-I${workspaceFolder}/core/source/sparc"
],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/opt/homebrew/bin/g++-13",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64",
"configurationProvider": "mesonbuild.mesonbuild"
},
{
"name": "WindowsLLVM",
"includePath": [
Expand Down
3 changes: 2 additions & 1 deletion core/examples/pgc/beatwave-3d.tw
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// NERSC Edison: 11 nodes, 7.5 minutes
// NERSC Cori-Haswell: 8 nodes, 7.2 minutes
// NERSC Cori-KNL: 8 nodes, 10 minutes
// NERSC Perlmutter-CPU: 2 nodes, 10 minutes
steps = 1000
timestep = 0.08
dump period = 0
Expand Down Expand Up @@ -71,7 +72,7 @@ new species 'e'
mass = 1
emission temperature = ( 0.1 , 0.1 , 0.1 )
particles per cell = ( 2 , 2 , 4 ) when density = 1
zboundary = emitting emitting
zboundary = (emitting emitting)
}

generate uniform 'e'
Expand Down
6 changes: 3 additions & 3 deletions core/source/base/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void CommandHandler::Evaluate(const Arg& arg,
// (used with internal MPI) //
//////////////////////////////

#ifdef USING_TW_MPI
#ifdef USE_TW_MPI

struct Launcher : tw::Thread
{
Expand Down Expand Up @@ -328,7 +328,7 @@ void TW_Interactive::Run()
// Standard MPI Launch //
/////////////////////////

#ifndef USING_TW_MPI
#ifndef USE_TW_MPI
int main(int argc,char *argv[])
{
int numOMPThreads=0; // indicates -c argument was not given
Expand Down Expand Up @@ -382,7 +382,7 @@ int main(int argc,char *argv[])
// Internal MPI Launch //
/////////////////////////

#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
int main(int argc,char *argv[])
{
int numMPIThreads=1,numOMPThreads=1;
Expand Down
4 changes: 2 additions & 2 deletions core/source/base/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void Simulation::SetupIO()

void Simulation::Run()
{
#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
// Wait until master thread is done
// TODO: fold this into TW_MPI's MPI_init
TW_MPI_Lock();
Expand Down Expand Up @@ -306,7 +306,7 @@ void Simulation::Run()

void Simulation::Test()
{
#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
// Wait until master thread is done
// TODO: fold this into TW_MPI's MPI_init
TW_MPI_Lock();
Expand Down
9 changes: 6 additions & 3 deletions core/source/concurrency/Tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ void Task::Initialize(tw::Int *doms,tw::Int *gcells,tw::Int *cyclic)
gpu = devices[whichDevice];
context = clCreateContext(NULL,1,&gpu,NULL,NULL,&err);
// Following is the updated function
commandQueue = clCreateCommandQueueWithProperties(context,gpu,NULL,&err);
//commandQueue = clCreateCommandQueueWithProperties(context,gpu,NULL,&err);
// Following is the deprecated function
//commandQueue = clCreateCommandQueue(context,gpu,0,&err);
commandQueue = clCreateCommandQueue(context,gpu,0,&err);

// Create kernels
std::string buildLog;
Expand Down Expand Up @@ -278,7 +278,10 @@ void Task::InitializeCLProgram(cl_program& program,const std::string& fileName,s
}
std::string header_and_source = CLDefinitions(gpu) + sourceString;
sourceText.resize(header_and_source.size()+1);
strcpy_s(&sourceText[0],sourceText.size(),header_and_source.c_str());
// Following is the updated function
//strcpy_s(&sourceText[0],sourceText.size(),header_and_source.c_str());
// Following is the deprecated function
strcpy(&sourceText[0],header_and_source.c_str());
sourceList[0] = &sourceText[0];

program = clCreateProgramWithSource(context,1,(const char**)&sourceList[0],NULL,&err);
Expand Down
6 changes: 3 additions & 3 deletions core/source/concurrency/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,19 @@ struct Task

void Lock()
{
#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
TW_MPI_Lock();
#endif
}
void Unlock()
{
#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
TW_MPI_Unlock();
#endif
}
void Complete()
{
#ifdef USING_TW_MPI
#ifdef USE_TW_MPI
TW_MPI_ThreadRef(strip[0].comm_cart,strip[0].Get_rank())->Complete();
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion core/source/concurrency/tw_mpi.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TurboWAVE non-conforming implementation of MPI

#define USING_TW_MPI
#define USE_TW_MPI

static const int MAX_THREADS = 256;
static const int MPI_PROC_NULL = -3;
Expand Down
37 changes: 22 additions & 15 deletions core/source/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
project('turbowave','cpp')
project('turbowave','cpp','c',
meson_version: '>=1.1.0',
version: '"4.8.0"',
default_options: ['cpp_std=c++17','buildtype=release']
)

# Meson philosophy is to give the source list explicitly.
# We can always copy and paste from a glob elsewhere.
src_base = ['base/3DFields.cpp', 'base/ComputeTool.cpp', 'base/DiscreteSpace.cpp', 'base/FFT.cpp', 'base/Functions.cpp', 'base/Injection.cpp', 'base/Injection_Test.cpp', 'base/Main.cpp', 'base/MetricSpace.cpp', 'base/MetricSpace_Test.cpp', 'base/Module.cpp', 'base/Region.cpp', 'base/Simulation.cpp']
src_con = ['concurrency/Tasks.cpp']
src_io = ['io/Diagnostics.cpp', 'io/Input.cpp', 'io/Units.cpp']
src_par = ['particles/Bundle.cpp', 'particles/Mover.cpp', 'particles/Mover_Test.cpp', 'particles/Particles.cpp', 'particles/Particles_Test.cpp', 'particles/Pusher.cpp', 'particles/Pusher_Test.cpp', 'particles/Slicer.cpp', 'particles/Tiler.cpp']
src_solv = ['solver/Electrostatic.cpp', 'solver/Elliptic.cpp', 'solver/Elliptic_Test.cpp', 'solver/FieldSolve.cpp', 'solver/Hyperbolic.cpp', 'solver/LaserSolve.cpp', 'solver/Numerics.cpp', 'solver/Parabolic.cpp', 'solver/Qstate.cpp', 'solver/Quantum.cpp', 'solver/SolidState.cpp']
src_sparc = ['sparc/Chemistry.cpp', 'sparc/Fluid.cpp', 'sparc/Fluid_Test.cpp', 'sparc/Physics.cpp', 'sparc/Physics_Test.cpp']

conf_data = configuration_data()
conf_data.set('TW_VERSION_STRING','"4.8.0"')
conf_data.set('TW_VERSION_STRING',meson.project_version())
conf_data.set('BIGENDIAN',get_option('bigendian'))
conf_data.set('VBITS',get_option('vbits'))
conf_data.set('USE_DESKTOP',not get_option('hpc'))
Expand All @@ -22,25 +35,19 @@ if get_option('omp')
endif
if get_option('ocl')
deps += [dependency('opencl')]
conf_data.set('CL_TARGET_OPENCL_VERSION','300')
conf_data.set('CL_TARGET_OPENCL_VERSION','120')
endif
if get_option('hpc')
deps += [dependency('mpi')]
else
src_con += ['concurrency/TW_MPI.cpp']
endif

# Meson philosophy is to give the source list explicitly.
# We can always copy and paste from a glob elsewhere.
src_base = ['base/3DFields.cpp', 'base/ComputeTool.cpp', 'base/DiscreteSpace.cpp', 'base/FFT.cpp', 'base/Functions.cpp', 'base/Injection.cpp', 'base/Injection_Test.cpp', 'base/Main.cpp', 'base/MetricSpace.cpp', 'base/MetricSpace_Test.cpp', 'base/Module.cpp', 'base/Region.cpp', 'base/Simulation.cpp']
src_con = ['concurrency/Tasks.cpp', 'concurrency/TW_MPI.cpp']
src_io = ['io/Diagnostics.cpp', 'io/Input.cpp', 'io/Units.cpp']
src_par = ['particles/Bundle.cpp', 'particles/Mover.cpp', 'particles/Mover_Test.cpp', 'particles/Particles.cpp', 'particles/Particles_Test.cpp', 'particles/Pusher.cpp', 'particles/Pusher_Test.cpp', 'particles/Slicer.cpp', 'particles/Tiler.cpp']
src_solv = ['solver/Electrostatic.cpp', 'solver/Elliptic.cpp', 'solver/Elliptic_Test.cpp', 'solver/FieldSolve.cpp', 'solver/Hyperbolic.cpp', 'solver/LaserSolve.cpp', 'solver/Numerics.cpp', 'solver/Parabolic.cpp', 'solver/Qstate.cpp', 'solver/Quantum.cpp', 'solver/SolidState.cpp']
src_sparc = ['sparc/Chemistry.cpp', 'sparc/Fluid.cpp', 'sparc/Fluid_Test.cpp', 'sparc/Physics.cpp', 'sparc/Physics_Test.cpp']
src_all = src_base + src_con + src_io + src_par + src_solv + src_sparc

configure_file(output: 'config.h', configuration: conf_data)
executable(
'tw3d',
src_all,
src_base + src_con + src_io + src_par + src_solv + src_sparc,
include_directories : incdir,
cpp_args: ['-std=c++17'],
dependencies: deps,
install: true
)
File renamed without changes.
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ User Reference
ref-fluid
ref-QO
ref-twutils
ref-boot

Developer Reference
-------------------
Expand Down
10 changes: 5 additions & 5 deletions docs/install-easy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ The following should work in any operating system, assuming compilers are instal

#. Use the installer to complete the sequence of steps in the ``Tasks`` area.

* You can usually accept default responses.
* On Cray, the platform and vector type popups should be set manually.
* For now use OpenMP for the accelerator.
* The installer can configure for GPGPU, but you may need to fulfill some prerequisites as root for the compiler to succeed.

.. note:: Pretty PowerShell

To get color working try ``Set-ItemProperty HKCU:\Console VirtualTerminalLevel -Type DWORD 1``. To get Unicode characters working try ``$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding`` (put this in the ``$PROFILE`` file to make it persist). If unicode is still not displayed correctly, start cycling fonts (right-click title bar and choose ``Properties``).

Runtime
-------

When ``twinstall`` is used, the executable installs to the conda environment. As a result, when outside the environment, the executable will not be found. However, one should understand that the executable itself does not depend on Anaconda or Python in any way. It can be manually installed anywhere.

Upgrade
-------

Expand Down
Loading

0 comments on commit 06edef5

Please sign in to comment.