Skip to content

Commit

Permalink
Merge pull request #3 from noelchalmers/feature/libp_update
Browse files Browse the repository at this point in the history
libp update
  • Loading branch information
noelchalmers authored Apr 14, 2022
2 parents 96c2215 + 6323560 commit 7e43740
Show file tree
Hide file tree
Showing 937 changed files with 29,713 additions and 3,724,445 deletions.
73 changes: 23 additions & 50 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,56 +1,29 @@
# Prerequisites
*.d
*
!/**/
!*.*
!makefile
!*/*/makefile
!*/*/Makefile
!LICENSE

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
.DS_STORE
*.vtu
*.dat
*.txt
*.eps
*.png
*.pdf
*.log
*.bmp
*.swp
*.orig
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
**/*.o
**/*.c~
*.m~
*.nvprof

*~
\#*
.\#*
.occa/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "occa"]
path = occa
url = https://github.com/libocca/occa
73 changes: 73 additions & 0 deletions BK/BK1/bk1.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
The MIT License (MIT)
Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#ifndef BK1_HPP
#define BK1_HPP 1

#include "core.hpp"
#include "mesh.hpp"
#include "solver.hpp"

using namespace libp;

class bk1Settings_t: public settings_t {
public:
bk1Settings_t(const int argc, char** argv, comm_t _comm);
void report();
};

class bk1_t: public solver_t {
public:
mesh_t mesh;

ogs::ogs_t ogs;
ogs::halo_t gHalo;

memory<dlong> GlobalToLocal;
deviceMemory<dlong> o_GlobalToLocal;

int Nfields;

kernel_t operatorKernel;
kernel_t forcingKernel;

bk1_t() = default;
bk1_t(platform_t& _platform, settings_t& _settings,
mesh_t& _mesh):
solver_t(_platform, _settings), mesh(_mesh) {
Setup(platform, settings, mesh);
}

//setup
void Setup(platform_t& _platform, settings_t& _settings,
mesh_t& _mesh);

void Run();
};


#endif

57 changes: 57 additions & 0 deletions BK/BK1/bk1Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
The MIT License (MIT)
Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include "bk1.hpp"

int main(int argc, char **argv){

// start up MPI
comm_t::Init(argc, argv);

{ /*Scope so everything is destructed before MPI_Finalize */
comm_t comm(comm_t::world().Dup());

bk1Settings_t settings(argc, argv, comm);
if (settings.compareSetting("VERBOSE", "TRUE"))
settings.report();

// set up platform
platform_t platform(settings);

// set up mesh
mesh_t mesh(platform, settings, comm);

// set up bp solver
bk1_t bk(platform, settings, mesh);

// run
bk.Run();
}

// close down MPI
comm_t::Finalize();
return LIBP_SUCCESS;
}
159 changes: 159 additions & 0 deletions BK/BK1/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#####################################################################################
#
#The MIT License (MIT)
#
#Copyright (c) 2017-2022 Tim Warburton, Noel Chalmers, Jesse Chan, Ali Karakus
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#
#####################################################################################

define BK1_HELP_MSG

Bakeoff Kernel 1 makefile targets:

make BK1 (default)
make clean
make clean-libs
make clean-kernels
make realclean
make info
make help

Usage:

make BK1
Build BK1 executable.
make clean
Clean the BK1 executable and object files.
make clean-libs
In addition to "make clean", also clean the mesh, ogs, and core libraries.
make clean-kernels
In addition to "make clean-libs", also cleans the cached OCCA kernels.
make realclean
In addition to "make clean-kernels", also clean 3rd party libraries.
make info
List directories and compiler flags in use.
make help
Display this help message.

Can use "make verbose=true" for verbose output.

endef

ifeq (,$(filter BK1 clean clean-libs clean-kernels \
realclean info help,$(MAKECMDGOALS)))
ifneq (,$(MAKECMDGOALS))
$(error ${BK1_HELP_MSG})
endif
endif

ifndef LIBP_MAKETOP_LOADED
ifeq (,$(wildcard ../../make.top))
$(error cannot locate ${PWD}/../../make.top)
else
include ../../make.top
endif
endif

#libraries
CORE_LIBS=mesh ogs core

#includes
INCLUDES=${LIBP_INCLUDES} \
-I${LIBP_LIBS_DIR}/include \
-I.


#defines
DEFINES =${LIBP_DEFINES} \
-DLIBP_DIR='"${LIBP_DIR}"'

#.cpp compilation flags
BK1_CXXFLAGS=${LIBP_CXXFLAGS} ${DEFINES} ${INCLUDES}

#link libraries
LIBS=-L${LIBP_LIBS_DIR} $(addprefix -l,$(CORE_LIBS)) \
${LIBP_LIBS}

#link flags
LFLAGS=${BK1_CXXFLAGS} ${LIBS}

#object dependancies
DEPS=$(wildcard *.hpp) \
$(wildcard $(LIBP_INCLUDE_DIR)/*.h) \
$(wildcard $(LIBP_INCLUDE_DIR)/*.hpp)

SRC =$(wildcard src/*.cpp)

OBJS=$(SRC:.cpp=.o)

.PHONY: all libp_libs clean clean-libs \
clean-kernels realclean help info BK1

all: BK1

libp_libs:
ifneq (,${verbose})
${MAKE} -C ${LIBP_LIBS_DIR} $(CORE_LIBS) verbose=${verbose}
else
@${MAKE} -C ${LIBP_LIBS_DIR} $(CORE_LIBS) --no-print-directory
endif

BK1:$(OBJS) bk1Main.o | libp_libs
ifneq (,${verbose})
$(LIBP_LD) -o BK1 bk1Main.o $(OBJS) $(LFLAGS)
else
@printf "%b" "$(EXE_COLOR)Linking $(@F)$(NO_COLOR)\n";
@$(LIBP_LD) -o BK1 bk1Main.o $(OBJS) $(LFLAGS)
endif

# rule for .cpp files
%.o: %.cpp $(DEPS) | libp_libs
ifneq (,${verbose})
$(LIBP_CXX) -o $*.o -c $*.cpp $(BK1_CXXFLAGS)
else
@printf "%b" "$(OBJ_COLOR)Compiling $(@F)$(NO_COLOR)\n";
@$(LIBP_CXX) -o $*.o -c $*.cpp $(BK1_CXXFLAGS)
endif

#cleanup
clean:
rm -f src/*.o *.o BK1

clean-libs: clean
${MAKE} -C ${LIBP_LIBS_DIR} clean

clean-kernels: clean-libs
rm -rf ${LIBP_DIR}/.occa/

realclean: clean-libs
${MAKE} -C ${OCCA_DIR} clean
rm -rf ${LIBP_DIR}/.occa/

help:
$(info $(value BK1_HELP_MSG))
@true

info:
$(info LIBP_DIR = $(LIBP_DIR))
$(info LIBP_ARCH = $(LIBP_ARCH))
$(info CXXFLAGS = $(BK1_CXXFLAGS))
$(info LIBS = $(LIBS))
@true
Loading

0 comments on commit 7e43740

Please sign in to comment.