Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upcxx #40

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# The name of our project is "MHMxx". CMakeLists files in this project can
# refer to the root source directory of the project as ${SIMCOV_SOURCE_DIR} and
# to the root binary directory of the project as ${SIMCOV_BINARY_DIR}
# refer to the root source directory of the project as ${SIMFORAGER_SOURCE_DIR} and
# to the root binary directory of the project as ${SIMFORAGER_BINARY_DIR}
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(SimCov)
project(SimForager)
#----------------------------------------------------------------------------------------#
# project specification
#----------------------------------------------------------------------------------------#
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION SIMCOV_BASE_VERSION)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/VERSION SIMFORAGER_BASE_VERSION)

# use PROJECT_SOURCE_DIR, not CMAKE_SOURCE_DIR
set(SIMCOV_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(SIMCOV_BINARY_DIR ${PROJECT_BINARY_DIR})
set(SIMFORAGER_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(SIMFORAGER_BINARY_DIR ${PROJECT_BINARY_DIR})

# include modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/Modules)
Expand Down Expand Up @@ -55,7 +55,7 @@ CHECK_SUBMODULES(upcxx-utils)

# set version
include_directories(include)
GET_GIT_VERSION(SIMCOV)
GET_GIT_VERSION(SIMFORAGER)

# add upcxx-utils
if (DEFINED ENV{UPCXX_UTILS_DIR} AND EXISTS $ENV{UPCXX_UTILS_DIR})
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
simforager is a forked adaptation of:

simcov 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), Arizona State
Expand All @@ -14,17 +16,17 @@ 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 others to do so.

# SimCov #
# SimForager #

This is a model for simulating the response of the immune system to infections in the lungs.
This is a model for simulating large amounts of [currently homogeneous] foragers.

## Installing and building

It requires [UPC++](https://bitbucket.org/berkeleylab/upcxx/wiki/Home), C++ and cmake.

This repo contains a submodule, so to install, it's best to run

`git clone --recurse-submodules [email protected]:AdaptiveComputationLab/simcov.git`
`git clone --recurse-submodules [email protected]:cswritlarge/simforager.git`

to fully initialize the submodules.

Expand All @@ -38,22 +40,21 @@ or

The executable will be installed in

`<simcov-repo-directory>/install/bin`
`<simforager-repo-directory>/install/bin`

## Running

To run, execute

`upcxx-run -n <number_processes> -N <number_nodes> -- simcov`
`upcxx-run -n <number_processes> -N <number_nodes> -- simforager`

To see the parameters available, run with `-h`.

It will create an output directory, which will contain a detailed log file (`simcov.log`). It will also create a file containing
all the configuration parameters (`simcov.config`).
It will create an output directory, which will contain a detailed log file (`simforager.log`). It will also create a file containing all the configuration parameters (`simforager.config`).

A run can also be executed with a config file as

`upcxx-run -n <number_processes> -N <number_nodes> -- simcov --config <config_file>`
`upcxx-run -n <number_processes> -N <number_nodes> -- simforager --config <config_file>`

The config file consists of a list of all the command line options as key-value pairs, with semi-colons denoting comments.
For example:
Expand Down
8 changes: 4 additions & 4 deletions build_hopper.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module load cmake/3.11.4-qkyj
module load openmpi/4.1.3-j6zb
module load upcxx/2020.10.0-6eh2

if [ -n "$SIMCOV_BUILD_ENV" ]; then
source $SIMCOV_BUILD_ENV
if [ -n "$SIMFORAGER_BUILD_ENV" ]; then
source $SIMFORAGER_BUILD_ENV
fi

upcxx_exec=`which upcxx`
Expand All @@ -32,11 +32,11 @@ SECONDS=0

rootdir=`pwd`

INSTALL_PATH=${SIMCOV_INSTALL_PATH:=$rootdir/install}
INSTALL_PATH=${SIMFORAGER_INSTALL_PATH:=$rootdir/install}

echo "Installing to $INSTALL_PATH"

rm -rf $INSTALL_PATH/bin/simcov
rm -rf $INSTALL_PATH/bin/simforager

if [ "$1" == "clean" ]; then
rm -rf .build
Expand Down
2 changes: 1 addition & 1 deletion configs/figure-7/simcov.config
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
output = results

; Directory containing files for lung model
lung-model = /users/projects/simcov/lungmodel/lung_model_data
lung-model = /users/projects/simforager/lungmodel/lung_model_data

; Show progress
progress = true
Expand Down
35 changes: 18 additions & 17 deletions include/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class Options {

void setup_log_file() {
if (!upcxx::rank_me()) {
string log_fname = output_dir + "/simcov.log";
string log_fname = output_dir + "/simforager.log";
// check to see if simcov.log exists. If so, rename it
if (file_exists(log_fname)) {
string new_log_fname = output_dir + "/simcov-" + get_current_time(true) + ".log";
string new_log_fname = output_dir + "/simforager-" + get_current_time(true) + ".log";
cerr << KLRED << "WARNING: " << KNORM << log_fname << " exists. Renaming to "
<< new_log_fname << endl;
if (rename(log_fname.c_str(), new_log_fname.c_str()) == -1)
Expand All @@ -109,7 +109,7 @@ class Options {

void set_random_infections(int num) {
for (int i = 0; i < num; i++) {
if (i % rank_n() != rank_me()) continue;
if (i % upcxx::rank_n() != upcxx::rank_me()) continue;
infection_coords.push_back(
{_rnd_gen->get(dimensions[0] * 0.1, dimensions[0] * 0.9),
_rnd_gen->get(dimensions[1] * 0.1, dimensions[1] * 0.9),
Expand All @@ -123,7 +123,7 @@ class Options {
vector<array<int, 3>> infections =
get_uniform_infections(num, dimensions[0], dimensions[1], dimensions[2]);
for (int i = 0; i < infections.size(); i++) {
if (i % rank_n() != rank_me()) continue;
if (i % upcxx::rank_n() != upcxx::rank_me()) continue;
infection_coords.push_back({infections[i][0], infections[i][1], infections[i][2], 0});
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ class Options {
}
}
for (int i = 0; i < coords_strs.size(); i++) {
if (i % rank_n() != rank_me()) continue;
if (i % upcxx::rank_n() != upcxx::rank_me()) continue;
auto coords_and_time = splitter(",", coords_strs[i]);
if (coords_and_time.size() == 4) {
try {
Expand Down Expand Up @@ -255,7 +255,8 @@ class Options {
int tcell_initial_delay = 10080;
int tcell_vascular_period = 5760;
int tcell_tissue_period = 1440;
int tcell_binding_period = 10;
// int tcell_binding_period = 10;
double tcell_binding_period = 10;
double max_binding_prob = 1.0;

double infectivity = 0.02;
Expand All @@ -274,7 +275,7 @@ class Options {
int antibody_period = 5760;

unsigned rnd_seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
string output_dir = "simcov-results-n" + to_string(upcxx::rank_n()) + "-N" +
string output_dir = "simforager-results-n" + to_string(upcxx::rank_n()) + "-N" +
to_string(upcxx::rank_n() / upcxx::local_team().rank_n());
int sample_period = 0;
int sample_resolution = 1;
Expand All @@ -287,8 +288,8 @@ class Options {

bool load(int argc, char **argv) {
// SIMCOV version v0.1-a0decc6-master (Release) built on 2020-04-08T22:15:40 with g++
string full_version_str = "SimCov version " + string(SIMCOV_VERSION) + "-" +
string(SIMCOV_BRANCH) + " built on " + string(SIMCOV_BUILD_DATE);
string full_version_str = "SimForager version " + string(SIMFORAGER_VERSION) + "-" +
string(SIMFORAGER_BRANCH) + " built on " + string(SIMFORAGER_BUILD_DATE);
vector<string> infection_coords_strs;

CLI::App app(full_version_str);
Expand Down Expand Up @@ -419,15 +420,15 @@ class Options {

upcxx::barrier();

_rnd_gen = make_shared<Random>(rnd_seed + rank_me());
_rnd_gen = make_shared<Random>(rnd_seed + upcxx::rank_me());

if (!lung_model_dir.empty()) {
auto model_dims = get_model_dims(lung_model_dir + "/alveolus.dat");
if (model_dims.size() < 3) return false;
for (int i = 0; i < 3; i++) {
if (model_dims[i] != dimensions[i]) {
dimensions = model_dims;
if (!rank_me())
if (!upcxx::rank_me())
cerr << KLRED << "WARNING: " << KNORM
<< "Setting dimensions to model data: " << dimensions[0] << ", " << dimensions[1]
<< ", " << dimensions[2] << endl;
Expand All @@ -437,7 +438,7 @@ class Options {
}

if (virion_clearance_rate * antibody_factor > 1.0) {
if (!rank_me())
if (!upcxx::rank_me())
cerr << "Invalid parameter settings: virion-clearance * antibody_factor > 1.\n"
<< "Reduce either or both of those settings\n";
return false;
Expand All @@ -453,28 +454,28 @@ class Options {

if (dimensions[0] % sample_resolution || dimensions[1] % sample_resolution ||
(dimensions[2] > 1 && dimensions[2] % sample_resolution)) {
if (!rank_me())
if (!upcxx::rank_me())
cerr << "Error: sample period " << sample_resolution
<< " must be a factor of all the dimensions\n";
return false;
}

for (int i = 0; i < 3; i++) {
if (dimensions[i] > whole_lung_dims[i]) {
if (!rank_me()) cerr << "Dimensions must be <= whole lung dimensions\n";
if (!upcxx::rank_me()) cerr << "Dimensions must be <= whole lung dimensions\n";
return false;
}
}
setup_output_dir();
setup_log_file();

init_logger(output_dir + "/simcov.log", verbose);
init_logger(output_dir + "/simforager.log", verbose);

#ifdef DEBUG
open_dbg("debug");
#endif

SLOG(KLBLUE, "SimCov version ", full_version_str, KNORM, "\n");
SLOG(KLBLUE, "SimForager version ", full_version_str, KNORM, "\n");

if (upcxx::rank_me() == 0) {
// print out all compiler definitions
Expand All @@ -498,7 +499,7 @@ class Options {
#endif
if (!upcxx::rank_me()) {
// write out configuration file for restarts
ofstream ofs(output_dir + "/simcov.config");
ofstream ofs(output_dir + "/simforager.config");
ofs << app.config_to_str(true, true);
}
upcxx::barrier();
Expand Down
8 changes: 4 additions & 4 deletions include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
extern "C" {
#endif

extern const char *SIMCOV_VERSION;
extern const char *SIMCOV_VERSION_DATE;
extern const char *SIMCOV_BUILD_DATE;
extern const char *SIMCOV_BRANCH;
extern const char *SIMFORAGER_VERSION;
extern const char *SIMFORAGER_VERSION_DATE;
extern const char *SIMFORAGER_BUILD_DATE;
extern const char *SIMFORAGER_BRANCH;

#define MAX_BUILD_KMER_STR "Maximum kmer len=MAX_BUILD_KMER"

Expand Down
119 changes: 119 additions & 0 deletions simforager_null.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
; These are version 1.0 test of 'null' forager parameters for SIMCoV
; This means a parameter-based translation of SIMCoV into SIMForager without yet
; changing anything about the existing SIMCoV code base

; Dimensions: x y z (assuming grid spacing of 5 microns)
dim = 500 500 1
; >> resulting in 225000000 total environment (epithelial) cells

; Whole lung dimensions: x y z (assuming grid spacing of 5 microns)
whole-lung-dim = 500 500 1

; Number of timesteps (assuming 1 min per timestep)
; Set to arbitrary small number to start
timesteps = 14400
; >> ten days

; Location of initial infections (omit for no infections); can be:
; list of space-separated coords x,y,z,timestep
; uniform:N (where N is an int, for N uniformly distributed starting points at time 0)
; random:N (where N is an int, for N randomly distributed starting points at time 0)
infection-coords = uniform:22500
; >> this is .001% of total grid cells

; Number of virions at initial infection locations
; Chosen to guarantee that at least one cell is infected at the start - see infectivity
initial-infection = 1
; >> initially 1000 combined with number of initial infection sites, this should yield a 1:100 ratio of grid cells to algae cells

; Average number of time steps to expressing virions after cell is infected
incubation-period = 0

; Average number of time steps to death after apoptosis is induced
apoptosis-period = 3

; Average number of time steps to death after a cell starts expresssing
expressing-period = 1000000

; Factor multiplied by number of virions to determine probability of infection
infectivity = 0.5
; SIMCoV paper default

; Multiplier reducing infectivity where inflammatory signal is present
; (the multiplier reducing infectivity should be between 0.9 and 0.7 based on values
; in literature demonstrating a reduction of cell death in vitro with IFN)
infectivity-multiplier = 1.0
; >> irrelevant

; Number of virions produced by expressing cell each time step
virion-production = 1.1
; this is SIMCoV default we're going with for now...

; Multiplier reducing virion production rate where inflammatory signal is present
; (the reduction should be represented by a multiplier betweeon 0.05 and 0.15)
virion-production-multiplier = 1.0

; Fraction by which virion count drops each time step
virion-clearance = 0.0
; >> effectively algae death rate; not considered here

; Fraction of virions that diffuse into all neighbors each time step
virion-diffusion = 0.0

; Amount of chemokine produced by expressing cells each time step
chemokine-production = 0.0

; Amount by which chemokine concentration drops each time step
chemokine-decay = 0.0

; Fraction of chemokine concentration that diffuses into all neighbors each time step
chemokine-diffusion = 1.0

; Minimum chemokine concentration that triggers a T cell
min-chemokine = 0.0
; >> this should allow fish (T-cells) to be present at start

; Impact of antibodies; multiplier for virion decay (setting to 1 means this has no effect)
antibody-factor = 1

; Number of time steps before antibodies start to be produced
antibody-period = 1000000
; >> WHAT!? NOBODY INVITED ANTIBODIES TO A REEF

; Number of tcells generated at each timestep for the whole lung
; This is scaled up 5000x from the mouse model (20 per minute)
tcell-generation-rate = 100
; >> for a stable population of fish (T-cells) throughout sim

; Number of time steps before T cells start to be produced
tcell-initial-delay = 0

; Average number of time steps to death for a T cell in the vasculature
tcell-vascular-period = 2

; Average number of time steps to death after a T cell extravasates
tcell-tissue-period = 1000000

; Number of time steps a T cell is bound to an epithelial cell when inducing apoptosis
tcell-binding-period = 2

; Max probability of a T cell binding to an infected cell in one time step
max-binding-prob = 1

; T cells in tissue follow the chemokine gradient
tcells-follow-gradient = false

; Random seed
seed = 29

; Number of timesteps between samples (set to 0 to disable sampling)
sample-period = 5

; Resolution for sampling
sample-resolution = 1

; Max. block dimension - larger means more locality but worse load balance. Set to 0 for largest possible.
max-block-dim = 10

; Output directory (automatically generated)
; output = results
Loading