Skip to content

Commit

Permalink
-- Remove OpenMP as they did on the master branch. OpenMP as
Browse files Browse the repository at this point in the history
    implemented won't work on Mac ARM64
  • Loading branch information
Robert Hubley committed Sep 10, 2024
1 parent 99a942d commit 197998d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 37 deletions.
2 changes: 0 additions & 2 deletions NINJA/DistanceCalculator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "sse2neon.h"
#endif

#include <omp.h> /* openmp */


class DistanceCalculator{
const float bl45[21][21];
Expand Down
26 changes: 0 additions & 26 deletions NINJA/DistanceReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,36 +63,26 @@ void DistanceReader::readDoubles(std::string **names, double** distances){
unsigned int begin = 0, end = 0, numBegin = 0, numEnd = 0;
int count = 0;

if (this->threads == 0){
omp_set_num_threads(omp_get_max_threads());
} else {
omp_set_num_threads(this->threads);
}
if (this->distCalc != NULL) {//using distCalc on input alignment
this->clustersEqual = new int[this->K];

for (int i=0; i<this->K; i++)
this->clustersEqual[i] = -1;

//#pragma omp parallel for
for (int i=0; i<this->K; i++){
//#pragma omp critical
if (this->clustersEqual[i] != -1){ //if this sequence is clustered, its distance to everyone else is maxed out
for (int j=i+1; j<this->K; j++)
distances[i][j-i-1] = this->distCalc->getMaxScore();
continue;
}
#pragma omp parallel for
for (int j=i+1; j<this->K; j++)
{
//#pragma omp critical
if (this->clustersEqual[j] != -1){
distances[i][j-i-1] = this->distCalc->getMaxScore(); //seq j is already clustered to another one, therefore every sequence will have maximum score to it.
continue;
}
distances[i][j-i-1] = this->distCalc->calc(i,j);
if (distances[i][j-i-1] == 0 && (*this->distCalc->A[i]) == (*this->distCalc->A[j])){
#pragma omp critical
this->clustersEqual[j] = i; //because I do not check again for this->clustersEqual[j], this could cluster it to a sequence that is not the first one to show up. however, it should get the same result.
}
}
Expand Down Expand Up @@ -134,38 +124,28 @@ void DistanceReader::read(std::string **names, int** distances){ //possibly wron
unsigned int begin = 0, end = 0, numBegin = 0, numEnd = 0;
int count = 0;

if (this->threads == 0){
omp_set_num_threads(omp_get_max_threads());
} else {
omp_set_num_threads(this->threads);
}
if (this->distCalc != NULL) {//using distCalc on input alignment
//int clustersEqual[this->K];
this->clustersEqual = new int[this->K];

for (int i=0; i<this->K; i++)
this->clustersEqual[i] = -1;

//#pragma omp parallel for
for (int i=0; i<this->K; i++){
//#pragma omp critical
if (this->clustersEqual[i] != -1){ //if this sequence is clustered, its distance to everyone else is maxed out
for (int j=i+1; j<this->K; j++)
distances[i][j-i-1] = this->distCalc->getMaxScore();
continue;
}
#pragma omp parallel for
for (int j=i+1; j<this->K; j++)
{
//#pragma omp critical
if (this->clustersEqual[j] != -1){
distances[i][j-i-1] = this->distCalc->getMaxScore(); //seq j is already clustered to another one, therefore every sequence will have maximum score to it.
continue;
}
//distances[i][j-i-1] = this->distCalc->testDifferenceCluster(i,j);
distances[i][j-i-1] = 100 * (int)(((100000000*this->distCalc->calc(i,j))+50)/100) ; // this gets the same rounding I have in the distance writer code
if (distances[i][j-i-1] == 0 && (*this->distCalc->A[i]) == (*this->distCalc->A[j])){
#pragma omp critical
this->clustersEqual[j] = i; //because I do not check again for this->clustersEqual[j], this could cluster it to a sequence that is not the first one to show up. however, it should get the same result.
}
}
Expand Down Expand Up @@ -213,12 +193,6 @@ void DistanceReader::readAndWrite(std::string **names, FILE* outFile){ //possibl
for(int i = 0; i < this->K; ++i)
distances[i] = new double[this->K];

if (this->threads == 0){
omp_set_num_threads(omp_get_max_threads());
} else {
omp_set_num_threads(this->threads);
}
#pragma omp parallel for
for (int i=0; i<this->K; i++){
for (int j=i+1; j<this->K; j++){
//distances[i][j-i-1] = this->distCalc->testDifferenceCluster(i,j);
Expand Down
2 changes: 1 addition & 1 deletion NINJA/DistanceReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Created on: Feb 13, 2016
* Author: michel
*/
#include "ExceptionHandler.hpp"
#include "DistanceCalculator.hpp"
#include "ExceptionHandler.hpp"

#ifndef Included_DistanceReader_H
#define Included_DistanceReader_H
Expand Down
8 changes: 1 addition & 7 deletions NINJA/DistanceReaderExtMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,15 @@ int DistanceReaderExtMem::read (std::string** names, float* R, FILE* diskD, floa

float* fBuff = new float[numColsToDisk];

omp_set_num_threads(omp_get_max_threads());

//TODO: implement threads here, more complicated that in the in memory function, but still feasible
if(this->distCalc != NULL){
while (row != K && buffPtr<buffSize) {

//interleave columns in the
#pragma omp parallel for
//interleave columns in the
for (int col=0; col<numColsToDisk; col++) {

float d = ((float)ceil((float)(10000000 * distCalc->calc(row, col))))/10000000;

#pragma omp atomic
R[row] += d;

fBuff[col] = d;
Expand All @@ -68,14 +64,12 @@ int DistanceReaderExtMem::read (std::string** names, float* R, FILE* diskD, floa
fwrite(fBuff,sizeof(float),numColsToDisk,diskD);

}
#pragma omp parallel for
for (int col=numColsToDisk; col<this->K; col++) {
#ifdef TEST_DIFF
float d = this->distCalc->testDifferenceCluster(row,col);
#endif
float d = ((float)ceil((float)(10000000 * distCalc->calc(row, col))))/10000000;

#pragma omp atomic
R[row] += d;

memD[row][col-numColsToDisk] = d;
Expand Down
2 changes: 1 addition & 1 deletion NINJA/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SOURCES += TreeNode.cpp
OBJECTS = $(SOURCES:.cpp=.o)

#CXXFLAGS = -std=gnu++11 -Wall -mssse3 -fopenmp
CXXFLAGS = -std=gnu++11 -Wall -fopenmp
CXXFLAGS = -std=gnu++11 -Wall
ifeq ($(shell uname -m),x86_64)
CXXFLAGS += -mssse3
endif
Expand Down

0 comments on commit 197998d

Please sign in to comment.