Giter VIP home page Giter VIP logo

pyamrex-1's Introduction

pyAMReX

Python3 Python3 API: Pre-Alpha License AMReX
linux macos windows

pyAMReX is part of AMReX.

Due to its highly experimental nature, we develop it currently in a separate respository.

We will add further information here once first development versions are ready for testing.

Users

to do

  • pip/pypa
  • conda-forge
  • spack
  • brew
  • ...

Usage

to do

import pyamrex

small_end = pyamrex.Int_Vect()
big_end = pyamrex.Int_Vect(2, 3, 4)

b = pyamrex.Box(small_end, big_end)
print(b)

# ...

Developers

If you are new to CMake, this short tutorial from the HEP Software foundation is the perfect place to get started with it.

If you just want to use CMake to build the project, jump into sections 1. Introduction, 2. Building with CMake and 9. Finding Packages.

Dependencies

pyAMReX depends on the following popular third party software.

Optional dependencies include:

Install Dependencies

macOS/Linux:

spack env activate -d .
# optional:
# spack add cuda
spack install

(in new terminals, re-activate the environment with spack env activate -d . again)

or macOS/Linux:

brew update
brew install ccache cmake libomp mpi4py numpy open-mpi python

Now, cmake --version should be at version 3.18.0 or newer.

Or go:

# optional:                                    --user
python3 -m pip install -U pip setuptools wheel
python3 -m pip install -U cmake

Configure your compiler

For example, using the Clang compiler:

export CC=$(which clang)
export CXX=$(which clang++)

If you also want to select a CUDA compiler:

export CUDACXX=$(which nvcc)
export CUDAHOSTCXX=$(which clang++)

Build & Test

From the base of the pyAMReX source directory, execute:

# optional controls (example):
#export AMREX_SPACEDIM=3
#export AMREX_MPI=ON
#export AMREX_OMP=ON
#export AMREX_GPU_BACKEND=CUDA
#export AMREX_SRC=$PWD/../amrex
#export CMAKE_BUILD_PARALLEL_LEVEL=8

# optional:                 --force-reinstall --user
python3 -m pip install -v .

If you are iterating on C++ builds, it might be faster to just call CMake:

cmake -S . -B build
cmake --build build -j 8  # repeat this step to fix compile errors

Build Options

If you are using the pip-driven install, selected AMReX CMake options can be controlled with environment variables:

Environment Variable Default & Values Description
AMREX_OMP ON/OFF Enable OpenMP
AMREX_GPU_BACKEND NONE/SYCL/CUDA/HIP On-node, accelerated GPU backend
AMREX_MPI ON/OFF Enable MPI
AMREX_PRECISION SINGLE/DOUBLE Precision of AMReX Real type
AMREX_SPACEDIM 1/2/3 Dimension of AMReX
AMREX_BUILD_SHARED_LIBS ON/OFF Build the core AMReX library as shared library
AMREX_SRC None Absolute path to AMReX source directory (preferred if set)
AMREX_REPO https://github.com/AMReX-Codes/amrex.git Repository URI to pull and build AMReX from
AMREX_BRANCH development Repository branch for AMREX_REPO
AMREX_INTERNAL ON/OFF Needs a pre-installed AMReX library if set to OFF
AMREX_LIBDIR None (note: not yet implemented) If set, search for pre-built AMReX C++ libraries (see below)
CMAKE_BUILD_PARALLEL_LEVEL 2 Number of parallel build threads

For example, one can also build against a local AMReX copy. Assuming AMReX' source is located in $HOME/src/amrex, then export AMREX_SRC=$HOME/src/amrex.

Or as a one-liner, assuming your AMReX source directory is located in ../amrex:

AMREX_SRC=$PWD/../amrex python3 -m pip install -v --force-reinstall .

Note that you need to use absolute paths for external source trees, because pip builds in a temporary directory.

Or build against an AMReX feature branch of a colleague. Assuming your colleague pushed AMReX to https://github.com/WeiqunZhang/amrex/ in a branch new-feature then

unset AMREX_SRC  # preferred if set
AMREX_REPO=https://github.com/WeiqunZhang/amrex.git AMREX_BRANCH=new-feature python3 -m pip install -v --force-reinstall .

You can speed up the install further if you pre-install AMReX, e.g. with a package manager. Set AMREX_INTERNAL=OFF and add installation prefix of AMReX to the environment variable CMAKE_PREFIX_PATH. Please see the short CMake tutorial that we linked above if this sounds new to you.

License

pyAMReX Copyright (c) 2021, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Innovation & Partnerships Office at [email protected].

NOTICE. This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit other to do so.

License for pyamrex can be found at LICENSE.

pyamrex-1's People

Contributors

ax3l avatar weiqunzhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.