Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2fffb77
initialization
cmontemuino Apr 12, 2016
9d98d92
Merge branch 'master' into multi-level-mw
cmontemuino Apr 12, 2016
858985e
routine signature simplification and result accumulation
cmontemuino Apr 13, 2016
2b1b9b4
shm preparation and some pseudo-code
cmontemuino Apr 15, 2016
cf3550c
right cmake conf for ubuntu
cmontemuino Apr 15, 2016
5aa2764
global master / node master processing
cmontemuino Apr 18, 2016
cb00a48
computation / communication interleaving improvement
cmontemuino Apr 19, 2016
03f5f33
fix processing with higher master-worker topology
cmontemuino Apr 20, 2016
defd7b6
fix processing with higher master-worker topology
cmontemuino Apr 20, 2016
b88bc40
improvement for the scenario with 1 node only
cmontemuino Apr 20, 2016
4b8e969
Direct output and all-work mode in in master
cmontemuino Apr 25, 2016
f67e74f
reduce number of messages used for coordination
cmontemuino Apr 29, 2016
5e7b880
deactivate sample generation at master level
cmontemuino May 2, 2016
b8f415b
revert back mspar code and bring makefile
cmontemuino May 29, 2016
7fc4ea2
semi-autonomous scheduling
cmontemuino Jun 6, 2016
3004ef3
fix shm rank gathering process
cmontemuino Jun 6, 2016
4b6c0ae
missing bcast for number of nodes to all processes
cmontemuino Jun 6, 2016
d3dc3e1
fix master-worker collection
cmontemuino Jun 6, 2016
3fe009e
fix sending results to node master
cmontemuino Jun 6, 2016
c48f5e9
add diagnose option
cmontemuino Jun 7, 2016
9c63b9e
simplify code and remove dead code
cmontemuino Jun 7, 2016
aebebe2
code simplification
cmontemuino Jun 8, 2016
3cfc76b
code documentation
cmontemuino Jun 8, 2016
c20c27a
documentation and fix output
cmontemuino Jun 13, 2016
c6189d1
Merge branch 'master' into feature/autonomous-local-masters
cmontemuino Jun 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#
#
# 'make' make executable file 'mspar'
# 'make' make executable file 'msparsm'
# 'make clean' removes all .o and executable files
#

Expand Down Expand Up @@ -33,22 +32,15 @@ RND=rand2.c
$(BIN)/%.o: %.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<

default: $(BIN)/mspar

# download: packages
# wget http://www.open-mpi.org/software/ompi/v1.8/downloads/openmpi-1.8.2.tar.gz
# tar -xf openmpi-1.8.2.tar.gz -C $(CURDIR)/packages

#packages:
# mkdir packages
default: $(BIN)/msparsm

clean:
rm -f $(BIN)/*
@echo ""
@echo "*** All resources were cleaned-up ***"
@echo ""

$(BIN)/mspar: $(OBJ)
$(BIN)/msparsm: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(RND_48) $(LIBS)
@echo ""
@echo "*** make complete: generated executable 'mspar' ***"
@echo "*** make complete: generated executable 'bin/msparsm' ***"
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,39 @@
msparsm
msParSm
=======

Parallel version of "ms" coalescent simulator using a master worker approach and a MPI implementation with on-demand scheduling.
The _msParSm_ application is an evolution of _msPar_ <sup>[(1)][1]</sup>, the parallel version of the coalescent simulation program
_ms_ <sup>[(2)][2]</sup>,
which removes the limitation for simulating long stretches of DNA sequences with large recombination rates,
without compromising the accuracy of the standard coalescence.

## Pre-requisites
- Linux GNU Compiler 4.9.1 (or greater)
- OpenMPI 1.10.1 (other releases in the branch 1.10 should be fine)
- Version 1.8.x could potentially be fine, but please notice that _msParSm_ was not fully tested with such version.
- CMake 3.5.1 (or greather) **OR** GNU Make 3.81 (or greater)

## How to Build
Create the makefile using CMake:
There are two ways for building _msParSm_: CMake and Make. If you have installed CMAKE with version greater than 3.5.0,
then go with CMake, otherwise you should use Make.

### CMake
```bash
cmake <src-path> -DCMAKE_INSTALL_PREFIX=<install-path>
```

Install using make:
### Make
```bash
make install
```
Binary files will be put into the `bin` folder (which is already _git ignored_).

## How to Use
Usage is the mostly the same as with traditional _ms_, but you need to run it through _OpenMPI_. Next example
will run the application using 4 threads:

```bash
mpirun -n 4 bin/msparsm 10 20 -seeds 40328 19150 54118 -t 100 -r 100 100000 -I 2 2 8 -eN 0.4 10.01 -eN 1 0.01 -en 0.25 2 0.2 -ej 3 2 1 -T > results.out
```

[1]: http://link.springer.com/chapter/10.1007/978-3-642-54420-0_32
[2]: http://home.uchicago.edu/~rhudson1/popgen356/OxfordSurveysEvolBiol7_1-44.pdf
26 changes: 15 additions & 11 deletions mspar.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ char *generateSamples(int samples, struct params parameters, unsigned maxsites,
*/
char* generateSample(struct params parameters, unsigned maxsites, int *bytes)
{
int segsites, offset;
size_t positionStrLength, gametesStrLenght;
int segsites;
size_t offset, positionStrLength, gametesStrLenght;
double probss, tmrca, ttot;
char *results;
char **gametes;
Expand All @@ -263,32 +263,38 @@ char* generateSample(struct params parameters, unsigned maxsites, int *bytes)
gametes = cmatrix(parameters.cp.nsam, parameters.mp.segsitesin+1 );

gensamResults = gensam(gametes, &probss, &tmrca, &ttot, parameters, &segsites);
results = doPrintWorkerResultHeader(segsites, probss, parameters, gensamResults.tree, &offset);

results = doPrintWorkerResultHeader(segsites, probss, parameters, gensamResults.tree);

offset = strlen(results);
*bytes = offset;

if(segsites > 0)
{
char *positionsStr = doPrintWorkerResultPositions(segsites, parameters.output_precision, gensamResults.positions);
positionStrLength = strlen(positionsStr);


char *gametesStr = doPrintWorkerResultGametes(segsites, parameters.cp.nsam, gametes);
gametesStrLenght = strlen(gametesStr);

results = realloc(results, offset + positionStrLength + gametesStrLenght + 1);
//sprintf(results, "%s%s", results, positionsStr);
results = realloc(results, offset + positionStrLength + gametesStrLenght + 2);

memcpy(results+offset, positionsStr, positionStrLength+1);

offset += positionStrLength;
*bytes += positionStrLength;

memcpy(results+offset, gametesStr, gametesStrLenght+1);

*bytes += gametesStrLenght;

free(positionsStr);
free(gametesStr);
if( parameters.mp.timeflag ) {
free(gensamResults.tree);
}
}

*bytes = offset;

return results;
}

Expand All @@ -299,7 +305,7 @@ char* generateSample(struct params parameters, unsigned maxsites, int *bytes)
* // xxx.x xx.xx x.xxxx x.xxxx
* segsites: xxx
*/
char *doPrintWorkerResultHeader(int segsites, double probss, struct params pars, char *treeOutput, int *bytes){
char *doPrintWorkerResultHeader(int segsites, double probss, struct params pars, char *treeOutput){
char *results;

int length = 3 + 1; // initially "\n//" and optionally a "\n" when there is no treeOutput;
Expand Down Expand Up @@ -332,8 +338,6 @@ char *doPrintWorkerResultHeader(int segsites, double probss, struct params pars,
sprintf(results, "%ssegsites: %d\n", results, segsites);
}

*bytes = length;

return results;
}

Expand Down