Skip to content

Commit

Permalink
Merge pull request #22 from sfiligoi/igor_build_gpu
Browse files Browse the repository at this point in the history
Request build on linux-gpu-cuda and cleanup code
  • Loading branch information
sfiligoi authored Dec 7, 2022
2 parents cec0e0e + 02f24fc commit 3c46739
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 15 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ jobs:
build-and-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, linux-gpu-cuda]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
with:
miniconda-version: "latest"
auto-update-conda: true
- name: Install
shell: bash -l {0}
Expand All @@ -32,12 +33,15 @@ jobs:
sudo mv -f /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.org
fi
df -h .
if [[ "$(uname -s)" == "Linux" ]];
then
conda create --yes -n unifrac -c conda-forge -c bioconda gxx_linux-64 hdf5 mkl-include lz4 zlib hdf5-static libcblas liblapacke make curl
conda create -q --yes -n unifrac -c conda-forge -c bioconda gxx_linux-64 hdf5 mkl-include lz4 zlib hdf5-static libcblas liblapacke make curl
else
conda create --yes -n unifrac -c conda-forge -c bioconda clangxx_osx-64 hdf5 mkl-include lz4 hdf5-static libcblas liblapacke make curl
conda create -q --yes -n unifrac -c conda-forge -c bioconda clangxx_osx-64 hdf5 mkl-include lz4 hdf5-static libcblas liblapacke make curl
fi
conda clean --yes -t
df -h .
conda activate unifrac
echo "$(uname -s)"
if [[ "$(uname -s)" == "Linux" ]];
Expand All @@ -52,19 +56,21 @@ jobs:
which h5c++
if [[ "$(uname -s)" == "Linux" ]];
then
./scripts/install_hpc_sdk.sh
./scripts/install_hpc_sdk.sh >/dev/null 2>/dev/null </dev/null
source setup_nv_h5.sh
fi
df -h .
export PERFORMING_CONDA_BUILD=True
make api && \
make main && \
make install && \
make test_binaries
df -h .
pushd src
if [[ "$(uname -s)" == "Linux" ]];
then
rm -f ~/.R/Makevars
conda install --yes -c conda-forge r-base
conda install -q --yes -c conda-forge r-base
unset CXXFLAGS
unset CFLAGS
unset DEBUG_CXXFLAGS
Expand Down
6 changes: 4 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ifndef NOGPU
ACCCPPFLAGS += -ta=tesla:ccall
else
ACCCPPFLAGS += -ta=tesla
# optional info
ACCCPPFLAGS += -Minfo=accel
endif
# optional info
ACCCPPFLAGS += -Minfo=accel
LDDFLAGS += -shlib -acc -Bstatic_pgi
EXEFLAGS += -acc -Bstatic_pgi
endif
Expand All @@ -79,8 +79,10 @@ else
endif

ifeq (,$(findstring pgi,$(COMPILER)))
ifneq ($(PERFORMING_CONDA_BUILD),True)
# basically, not gcc
CPPFLAGS += -Wextra -Wno-unused-parameter
endif
endif

BLASLIB=-llapacke -lcblas
Expand Down
3 changes: 2 additions & 1 deletion src/unifrac_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ static int sync_printf(const char *format, ...) {
va_start(args, format);

pthread_mutex_lock(&printf_mutex);
vprintf(format, args);
int cnt = vprintf(format, args);
pthread_mutex_unlock(&printf_mutex);

va_end(args);
return cnt;
}

static void sig_handler(int signo) {
Expand Down
47 changes: 41 additions & 6 deletions src/unifrac_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,23 @@ namespace SUCMP_NM {

public:
const unsigned int start_idx;
const unsigned int stop_idx;
const unsigned int n_samples;
const uint64_t n_samples_r;
TFloat* const buf;

UnifracTaskVector(std::vector<double*> &_dm_stripes, const su::task_parameters* _task_p)
: dm_stripes(_dm_stripes), task_p(_task_p)
, start_idx(task_p->start), n_samples(task_p->n_samples)
, start_idx(task_p->start), stop_idx(task_p->stop), n_samples(task_p->n_samples)
, n_samples_r(((n_samples + UNIFRAC_BLOCK-1)/UNIFRAC_BLOCK)*UNIFRAC_BLOCK) // round up
, buf((dm_stripes[start_idx]==NULL) ? NULL : new TFloat[n_samples_r*(task_p->stop-start_idx)]) // dm_stripes could be null, in which case keep it null
, buf((dm_stripes[start_idx]==NULL) ? NULL : new TFloat[n_samples_r*(stop_idx-start_idx)]) // dm_stripes could be null, in which case keep it null
{
TFloat* const ibuf = buf;
if (ibuf != NULL) {
#ifdef _OPENACC
const uint64_t bufels = n_samples_r * (task_p->stop-start_idx);
const uint64_t bufels = n_samples_r * (stop_idx-start_idx);
#endif
for(unsigned int stripe=start_idx; stripe < task_p->stop; stripe++) {
for(unsigned int stripe=start_idx; stripe < stop_idx; stripe++) {
double * dm_stripe = dm_stripes[stripe];
TFloat * buf_stripe = this->operator[](stripe);
for(unsigned int j=0; j<n_samples; j++) {
Expand All @@ -86,6 +87,9 @@ namespace SUCMP_NM {
}
}

UnifracTaskVector<TFloat>(const UnifracTaskVector<TFloat>& ) = delete;
UnifracTaskVector<TFloat>& operator= (const UnifracTaskVector<TFloat>&) = delete;

TFloat * operator[](unsigned int idx) { return buf+((idx-start_idx)*n_samples_r);}
const TFloat * operator[](unsigned int idx) const { return buf+((idx-start_idx)*n_samples_r);}

Expand All @@ -95,10 +99,10 @@ namespace SUCMP_NM {
TFloat* const ibuf = buf;
if (ibuf != NULL) {
#ifdef _OPENACC
const uint64_t bufels = n_samples_r * (task_p->stop-start_idx);
const uint64_t bufels = n_samples_r * (stop_idx-start_idx);
#pragma acc exit data copyout(ibuf[:bufels])
#endif
for(unsigned int stripe=start_idx; stripe < task_p->stop; stripe++) {
for(unsigned int stripe=start_idx; stripe < stop_idx; stripe++) {
double * dm_stripe = dm_stripes[stripe];
TFloat * buf_stripe = this->operator[](stripe);
for(unsigned int j=0; j<n_samples; j++) {
Expand Down Expand Up @@ -147,6 +151,9 @@ namespace SUCMP_NM {
: dm_stripes(baseObj.dm_stripes), dm_stripes_total(baseObj.dm_stripes_total), task_p(baseObj.task_p) {}
*/

UnifracTaskBase<TFloat,TEmb>(const UnifracTaskBase<TFloat,TEmb>& ) = delete;
UnifracTaskBase<TFloat,TEmb>& operator= (const UnifracTaskBase<TFloat,TEmb>&) = delete;

virtual ~UnifracTaskBase()
{
#ifdef _OPENACC
Expand Down Expand Up @@ -316,6 +323,8 @@ namespace SUCMP_NM {
, embedded_proportions(_embedded_proportions), max_embs(_max_embs) {}
*/

UnifracTask<TFloat,TEmb>(const UnifracTask<TFloat,TEmb>& ) = delete;
UnifracTask<TFloat,TEmb>& operator= (const UnifracTask<TFloat,TEmb>&) = delete;

virtual ~UnifracTask() {}

Expand Down Expand Up @@ -346,6 +355,9 @@ namespace SUCMP_NM {
#pragma acc enter data create(zcheck[:n_samples],sums[:n_samples])
}

UnifracUnnormalizedWeightedTask<TFloat>(const UnifracUnnormalizedWeightedTask<TFloat>& ) = delete;
UnifracUnnormalizedWeightedTask<TFloat>& operator= (const UnifracUnnormalizedWeightedTask<TFloat>&) = delete;

virtual ~UnifracUnnormalizedWeightedTask()
{
#ifdef _OPENACC
Expand Down Expand Up @@ -381,6 +393,9 @@ namespace SUCMP_NM {
#pragma acc enter data create(zcheck[:n_samples],sums[:n_samples])
}

UnifracNormalizedWeightedTask<TFloat>(const UnifracNormalizedWeightedTask<TFloat>& ) = delete;
UnifracNormalizedWeightedTask<TFloat>& operator= (const UnifracNormalizedWeightedTask<TFloat>&) = delete;

virtual ~UnifracNormalizedWeightedTask()
{
#ifdef _OPENACC
Expand Down Expand Up @@ -421,6 +436,9 @@ namespace SUCMP_NM {
#pragma acc enter data create(zcheck[:n_samples],stripe_sums[:n_samples],sums[:bsize])
}

UnifracUnweightedTask<TFloat>(const UnifracUnweightedTask<TFloat>& ) = delete;
UnifracUnweightedTask<TFloat>& operator= (const UnifracUnweightedTask<TFloat>&) = delete;

virtual ~UnifracUnweightedTask()
{
#ifdef _OPENACC
Expand Down Expand Up @@ -450,6 +468,9 @@ namespace SUCMP_NM {
UnifracGeneralizedTask(std::vector<double*> &_dm_stripes, std::vector<double*> &_dm_stripes_total, unsigned int _max_embs, const su::task_parameters* _task_p)
: UnifracTask<TFloat,TFloat>(_dm_stripes,_dm_stripes_total,_max_embs,_task_p) {}

UnifracGeneralizedTask<TFloat>(const UnifracGeneralizedTask<TFloat>& ) = delete;
UnifracGeneralizedTask<TFloat>& operator= (const UnifracGeneralizedTask<TFloat>&) = delete;

virtual void run(unsigned int filled_embs, const TFloat * __restrict__ length) {_run(filled_embs, length);}

void _run(unsigned int filled_embs, const TFloat * __restrict__ length);
Expand Down Expand Up @@ -516,6 +537,8 @@ namespace SUCMP_NM {
, embedded_proportions(_embedded_proportions), embedded_counts(initialize_embedded<TFloat>()), sample_total_counts(_sample_total_counts), max_embs(_max_embs) {}
*/

UnifracVawTask<TFloat,TEmb>(const UnifracVawTask<TFloat,TEmb>& ) = delete;
UnifracVawTask<TFloat,TEmb>& operator= (const UnifracVawTask<TFloat,TEmb>&) = delete;

virtual ~UnifracVawTask()
{
Expand Down Expand Up @@ -554,6 +577,9 @@ namespace SUCMP_NM {
unsigned int _max_embs, const su::task_parameters* _task_p)
: UnifracVawTask<TFloat,TFloat>(_dm_stripes,_dm_stripes_total,_sample_total_counts,_max_embs,_task_p) {}

UnifracVawUnnormalizedWeightedTask<TFloat>(const UnifracVawUnnormalizedWeightedTask<TFloat>& ) = delete;
UnifracVawUnnormalizedWeightedTask<TFloat>& operator= (const UnifracVawUnnormalizedWeightedTask<TFloat>&) = delete;

virtual void run(unsigned int filled_embs, const TFloat * __restrict__ length) {_run(filled_embs, length);}

void _run(unsigned int filled_embs, const TFloat * __restrict__ length);
Expand All @@ -566,6 +592,9 @@ namespace SUCMP_NM {
unsigned int _max_embs, const su::task_parameters* _task_p)
: UnifracVawTask<TFloat,TFloat>(_dm_stripes,_dm_stripes_total,_sample_total_counts,_max_embs,_task_p) {}

UnifracVawNormalizedWeightedTask<TFloat>(const UnifracVawNormalizedWeightedTask<TFloat>& ) = delete;
UnifracVawNormalizedWeightedTask<TFloat>& operator= (const UnifracVawNormalizedWeightedTask<TFloat>&) = delete;

virtual void run(unsigned int filled_embs, const TFloat * __restrict__ length) {_run(filled_embs, length);}

void _run(unsigned int filled_embs, const TFloat * __restrict__ length);
Expand All @@ -578,6 +607,9 @@ namespace SUCMP_NM {
unsigned int _max_embs, const su::task_parameters* _task_p)
: UnifracVawTask<TFloat,uint32_t>(_dm_stripes,_dm_stripes_total,_sample_total_counts,_max_embs,_task_p) {}

UnifracVawUnweightedTask<TFloat>(const UnifracVawUnweightedTask<TFloat>& ) = delete;
UnifracVawUnweightedTask<TFloat>& operator= (const UnifracVawUnweightedTask<TFloat>&) = delete;

virtual void run(unsigned int filled_embs, const TFloat * __restrict__ length) {_run(filled_embs, length);}

void _run(unsigned int filled_embs, const TFloat * __restrict__ length);
Expand All @@ -590,6 +622,9 @@ namespace SUCMP_NM {
unsigned int _max_embs, const su::task_parameters* _task_p)
: UnifracVawTask<TFloat,TFloat>(_dm_stripes,_dm_stripes_total,_sample_total_counts,_max_embs,_task_p) {}

UnifracVawGeneralizedTask<TFloat>(const UnifracVawGeneralizedTask<TFloat>& ) = delete;
UnifracVawGeneralizedTask<TFloat>& operator= (const UnifracVawGeneralizedTask<TFloat>&) = delete;

virtual void run(unsigned int filled_embs, const TFloat * __restrict__ length) {_run(filled_embs, length);}

void _run(unsigned int filled_embs, const TFloat * __restrict__ length);
Expand Down

0 comments on commit 3c46739

Please sign in to comment.