Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Oct 7, 2023
1 parent 890bb7d commit 2597f70
Show file tree
Hide file tree
Showing 219 changed files with 11,948 additions and 2,936 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ jobs:
cmake $GITHUB_WORKSPACE \
-DENABLE_SAMRAI_TESTS=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DlowResourceTests=ON \
-DCMAKE_CXX_FLAGS="-DPHARE_DIAG_DOUBLES=1 -O2"
-DCMAKE_CXX_FLAGS="-DPHARE_DIAG_DOUBLES=1 -O2" \
-DtestDuringBuild=ON
- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.mkn*
bin
build
subprojects
Expand Down
26 changes: 10 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cmake_minimum_required (VERSION 3.9)

project(PHARE VERSION 0.1 LANGUAGES CXX)
set(PHARE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})

include("${PHARE_PROJECT_DIR}/res/cmake/policies.cmake" NO_POLICY_SCOPE)
include(CheckCXXCompilerFlag)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE)
Expand All @@ -10,31 +14,21 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
endif()

if (POLICY CMP0074) # hides warning about ${PACKAGE}_ROOT variables
cmake_policy(SET CMP0074 NEW)
endif()
if (POLICY CMP0069) # allow LTO if available, requires cmake 3.9 (released August 2017)
cmake_policy(SET CMP0069 NEW)
endif()
find_package(PythonInterp 3.0 REQUIRED)
include("${PHARE_PROJECT_DIR}/res/cmake/options.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/def.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/coverage.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/dep.cmake")

# Enables -fPIC typically required for shared libraries with dependencies. e.g. pybind modules
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include(CheckCXXCompilerFlag)
find_program(Git git)
find_package(PythonInterp 3.0 REQUIRED)

set(PHARE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

include_directories(${PHARE_PROJECT_DIR}/src)

include("${PHARE_PROJECT_DIR}/res/cmake/options.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/def.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/coverage.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/dep.cmake")
include("${PHARE_PROJECT_DIR}/res/cmake/cppcheck.cmake")

# set standard after dependencies to avoid potential conflicts
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down
36 changes: 36 additions & 0 deletions mkn.cuda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /usr/bin/env bash

set -ex

CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

mkdir -p $CWD/build
[ ! -d "$CWD/build" ] && echo "mkn expects cmake configured build directory" && exit 1

MKN_X_FILE=${MKN_X_FILE:-settings}
MKN_MPI_X_FILE=${MKN_MPI_X_FILE:-res/mkn/mpi}
MKN_GPU_X_FILE=${MKN_GPU_X_FILE:-res/mkn/clang_cuda}
export MKN_LIB_LINK_LIB=1

exit 0

# verify compiler setup
# mkn clean build -x ${MKN_GPU_X_FILE} -ga -DKUL_GPU_CUDA dbg -p mkn.gpu_depositor run test

[ ! -d ./subprojects/thrust ] && \
git clone https://github.com/NVIDIA/thrust \
-b main subprojects/thrust --depth 10 --shallow-submodules --recursive
[ ! -d ./subprojects/cuda-samples ] && \
git clone https://github.com/NVIDIA/cuda-samples \
-b main subprojects/cuda-samples --depth 10 --shallow-submodules --recursive


# gtest doens't like mpi compilers
#mkn clean build -x ${MKN_X_FILE} -p test_diagnostics -tKOd google.test,+

#mkn clean build -x ${MKN_MPI_X_FILE} -dtKOp py

# mkn clean build -x ${MKN_MPI_X_FILE} -p test_diagnostics -KO 9 test run
# mkn clean build -x ${MKN_GPU_X_FILE} -Oa -DKUL_GPU_CUDA run

#mkn clean build -x ${MKN_GPU_X_FILE} -Op cpp
28 changes: 28 additions & 0 deletions mkn.rocm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /usr/bin/env bash

set -ex

CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

MKN_X_FILE=${MKN_X_FILE:-settings}
MKN_MPI_X_FILE=${MKN_MPI_X_FILE:-res/mkn/mpi}
MKN_GPU_X_FILE=${MKN_GPU_X_FILE:-res/mkn/hip}

mkdir -p $CWD/build
[ ! -d "$CWD/build" ] && echo "mkn expects cmake configured build directory" && exit 1

export MKN_LIB_LINK_LIB=1

# verify compiler setup
# mkn clean build -x ${MKN_GPU_X_FILE} -ga -DKUL_GPU_ROCM dbg -p mkn.gpu_depositor run test

# git clone https://github.com/NVIDIA/thrust -b 1.13.0 subprojects/thrust --depth 10 --shallow-submodules --recursive

# gtest doens't like mpi compilers
mkn clean build -x ${MKN_X_FILE} -p test_diagnostics -tKOd google.test,+

mkn clean build -x ${MKN_MPI_X_FILE} -dtKOp py

mkn clean build -x ${MKN_MPI_X_FILE} -p test_diagnostics -KO 9 test run

mkn clean build -x ${MKN_GPU_X_FILE} -Oa -DKUL_GPU_ROCM run
214 changes: 214 additions & 0 deletions mkn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
#! clean build -x mpi -dtKOp py

name: phare

property:
MPI_INC: /usr/include #/hdf5/mpich #/usr/include/hdf5/openmpi #/usr/local/netcdf/include
MPI_LIB: hdf5
MPI_PTH: /usr/local/lib #/opt/conda/envs/vscode/lib
mkn.gpu: -DPHARE_HAVE_MKN_GPU=1 -DMKN_GPU_CUDA=1 -DPHARE_WITH_KUL=1
gpu.args: -DPHARE_HAVE_RAJA=1 -DPHARE_WITH_GPU=1 ${mkn.gpu} -DHAVE_RAJA=1 -DHAVE_CUDA=1

profile:
- name: umpira_raja_base
arg: -DPHARE_HAVE_RAJA=1 -DPHARE_HAVE_UMPIRE=1

- name: base
arg: -Wno-macro-redefined -Wno-unknown-cuda-version -DPHARE_HAS_HIGHFIVE=0

- name: gpu_base
parent: base
dep: mkn.gpu llnl.raja[lib]
arg: ${gpu.args}

- name: core
parent: base
inc: src subprojects
src: src/core
# dep: mkn.kul
out: phare_core


- name: test_base
inc: .
dep: google.test

- name: test_core
parent: test_base
self: core
# test: tests/core/(\w)/(test_.*).cpp

- name: amr
parent: base
self: core
dep: llnl.samrai(https://github.com/mkn-nix/llnl.samrai) #llnl.raja[lib] mkn.gpu #llnl.umpire[lib]
lib: hdf5_openmpi
src: src/amr
out: phare_amr

- name: test_amr
parent: test_base
self: amr

- name: diagnostic
self: amr
dep: hpc.highfive(https://github.com/mkn-nix/hpc.highfive)
inc: build/subprojects/highfive/include
${MPI_INC}
lib: ${MPI_LIB}
path: ${MPI_PTH}

- name: simulator
parent: base
self: diagnostic
out: phare_simulator

- name: exe
parent: gpu_base
self: simulator init
dep: lang.pybind11
main: src/phare/phare.cpp
mod: lang.python3
env: PYTHONPATH=${MKN_ROOT}:${MKN_ROOT}/tests/diagnostic:${MKN_ROOT}/build:${MKN_ROOT}/pyphare

- name: init
src: src/initializer/data_provider.cpp
self: core
out: phare_initializer
mode: shared # static singleton dict lives here

- name: pybind
# parent: base
mode: shared
dep: lang.pybind11
mod: lang.pybind11 lang.python3

- name: dictator
parent: pybind
self: init
src: src/initializer/dictator.cpp
install: build/pybindlibs
out: dictator

- name: cpp
parent: pybind
# lib: numa
# arg: -DPHARE_WITH_GPU -DKUL_GPU_CUDA
arg: ${gpu.args}

self: simulator init gpu_base
src: src/python3/cpp_simulator.cpp
install: build/pybindlibs
#test: tests/amr/solvers/ppc/test_gpu_solverppc.cpp
out: cpp

- name: cpp_etc
parent: pybind
self: simulator
src: src/python3/cpp_etc.cpp
install: build/pybindlibs
out: cpp_etc
arg: -DPHARE_HAS_HIGHFIVE=0

- name: py
self: dictator cpp_etc simulator

- name: test
parent: base
self: init simulator
dep: lang.pybind11 google.test
mod: lang.python3
inc: .
link: -pthread

- name: test_diagnostics
parent: test
mode: none
mod: lang.python3
test:
tests/diagnostic/test-diagnostics_1d.cpp
tests/diagnostic/test-diagnostics_2d.cpp
env: PYTHONPATH=${MKN_ROOT}:${MKN_ROOT}/build/tests/diagnostic:${MKN_ROOT}/build:${MKN_ROOT}/pyphare

- name: bench
self: core
inc: . tools
dep: google.benchmark
main: tools/bench/core/data/particles/interop.cpp
link: -pthread

- name: gpu_pusher
parent: test
self: bench
inc: .
dep: mkn.gpu
arg: -DPHARE_WITH_GPU
env: PYTHONPATH=${MKN_ROOT}:${MKN_ROOT}/tools/bench/core/numerics/pusher:${MKN_ROOT}/build:${MKN_ROOT}/pyphare

- name: rocm_pusher
parent: gpu_pusher
main: tools/bench/core/numerics/pusher/gpu.cpp
arg: -DKUL_GPU_ROCM
env: PYTHONPATH=${MKN_ROOT}:${MKN_ROOT}/tools/bench/core/numerics/pusher:${MKN_ROOT}/build:${MKN_ROOT}/pyphare

- name: cuda_pusher
parent: gpu_pusher
main: tests/amr/solvers/ppc/test_gpu_solverppc.cpp #tools/bench/core/numerics/pusher/gpu.cpp
arg: -DKUL_GPU_CUDA
inc: subprojects/thrust
env: PYTHONPATH=${MKN_ROOT}:${MKN_ROOT}/tools/bench/core/numerics/pusher:${MKN_ROOT}/build:${MKN_ROOT}/pyphare

# - name: cuda_bandwidth_test
# main: subprojects/cuda-samples/Samples/bandwidthTest/bandwidthTest.cu
# inc: subprojects/cuda-samples/Common

- name: c_depositor
test: tools/hw/gpu/bench/depositor.cpp

- name: mkn.gpu_depositor
dep: mkn.gpu
test: tools/hw/gpu/bench/depositor.mkn.gpu.cpp

# mkn clean build test run -p mkn.sheath.hip -x res/mkn/hcc.yaml -O
- name: mkn.sheath.hip
dep: mkn.gpu
test: tools/hw/gpu/bench/sheath-gpu.hip.cpp

- name: mkn.sheath.cuda
dep: mkn.gpu
test: tools/hw/gpu/bench/sheath-gpu.cuda.cpp

- name: test_core_gpu_mkn
self: core
arg: -DPHARE_WITH_GPU=1 -DPHARE_HAVE_MKN_GPU=1 -DMKN_GPU_CUDA=1
dep: google.test mkn.gpu nvidia.thrust
main: tests/core/data/test_vector.cpp

- name: gpu_test
parent: test
self: simulator init
arg: |
-DHAVE_RAJA
-DHAVE_UMPIRE
-DRAJA_ENABLE_CUDA=1
-DUMPIRE_ENABLE_CUDA=1
-DPHARE_WITH_GPU=1
-DPHARE_HAS_HIGHFIVE=1
-DPHARE_WITH_KUL=1
-DKUL_GPU_CUDA=1
test:
tests/core/data/ndarray/test_main.cpp

# tests/core/numerics/ion_updater/test_updater.cpp
# tests/core/numerics/interpolator/test_main.cpp
# tests/core/data/field/test_field.cpp
# tests/core/data/vecfield/test_main.cpp
# tests/core/data/ions/test_ions.cpp
# tests/core/data/electrons/test_electrons.cpp
# tests/core/numerics/ampere/test_main.cpp
# tests/core/numerics/faraday/test_main.cpp
# tests/core/numerics/ohm/test_main.cpp

- name: format
mod: |
clang.format{init{style: file, paths: src}}
19 changes: 14 additions & 5 deletions pyphare/pyphare/core/phare_utilities.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import math
import numpy as np



def is_nd_array(arg):
return isinstance(arg, np.ndarray)


def all_iterables(*args):
"""
return true if all arguments are either lists or tuples
"""
return all([isinstance(arg, list) or isinstance(arg, tuple) for arg in args])
return all([isinstance(arg, (tuple, list)) or is_nd_array(arg) for arg in args])


def none_iterable(*args):
"""
return true if none of the arguments are either lists or tuples
"""
return all([not isinstance(arg, list) and not isinstance(arg, tuple) for arg in args])
return all([not isinstance(arg, (tuple, list)) and not is_nd_array(arg) for arg in args])


def equal_size(*args):
Expand Down Expand Up @@ -44,11 +50,9 @@ def listify(arg):


def is_scalar(arg):
return not isinstance(arg, (list, tuple)) and not is_nd_array(arg)
return none_iterable(arg)


def is_nd_array(arg):
return isinstance(arg, np.ndarray)


def np_array_ify(arg, size = 1):
Expand Down Expand Up @@ -159,3 +163,8 @@ def deep_copy(item, memo, excludes=[]):
setattr(that, key, deepcopy(value, memo))
return that


def NO_GUI():
import matplotlib as mpl
mpl.use("Agg")

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# wheel might be need to build other deps
wheel
dill
ddt
h5py
Expand Down
Loading

0 comments on commit 2597f70

Please sign in to comment.