Skip to content

Commit

Permalink
Start adding MPI library.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtschwar committed Dec 2, 2019
1 parent 0267b98 commit 530de40
Show file tree
Hide file tree
Showing 9 changed files with 841 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
**/__pycache__
**/Results
*.pyc
3D/Tilt_Series/*
3D/Tilt_Series/*
*.so
2 changes: 1 addition & 1 deletion 3D/ART.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
tiltSeries = None

# Generate Tilt Angles.
tiltAngles = np.load('Tilt_Series/'+file_name+'_tiltAngles.npy')
tiltAngles = np.load('../Tilt_Series/'+file_name+'_tiltAngles.npy')

# Generate measurement matrix
A = parallelRay(Nray, tiltAngles)
Expand Down
13 changes: 8 additions & 5 deletions 3D/Utils/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
CXX = g++-8
CXX = g++-8
MPXX = mpic++
CXXFLAGS = -O3 -Wno-div-by-zero -fopenmp -shared -std=c++11 -undefined dynamic_lookup -ffast-math -march=native
EIGEN = -I /opt/local/include/eigen3
PYBIND11 = `python3 -m pybind11 --includes`
ctvlib_config = ctvlib`python3-config --extension-suffix`
PYCONFIG = ctvlib`python3-config --extension-suffix`
MPICONFIG = mpi_ctvlib`python3-config --extension-suffix`

all: ctvlib

ctvlib: ctvlib.cpp ctvlib.hpp
$(CXX) $(CXXFLAGS) $(EIGEN) $(PYBIND11) ctvlib.cpp -o $(ctvlib_config)
$(CXX) $(CXXFLAGS) $(EIGEN) $(PYBIND) $(PYBIND11) ctvlib.cpp -o $(PYCONFIG)

mpiCtvlib: mpi_ctvlib.cpp mpi_ctvlib.hpp
$(MPXX) $(CXXFLAGS) $(EIGEN) $(PYBIND) $(PYBIND11) mpi_ctvlib.cpp -o $(MPICONFIG)
18 changes: 9 additions & 9 deletions 3D/Utils/ctvlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ ctvlib::ctvlib(int Ns, int Nray, int Nproj)
// Initialize the 3D Matrices as zeros.
for (int i=0; i < Nslice; i++)
{
recon[i] = Mat::Zero(Ny, Ny);
temp_recon[i] = Mat::Zero(Ny, Ny);
tv_recon[i] = Mat::Zero(Ny,Ny);
recon[i] = Mat::Zero(Ny, Nz);
temp_recon[i] = Mat::Zero(Ny, Nz);
tv_recon[i] = Mat::Zero(Ny,Nz);
}
}

Expand Down Expand Up @@ -77,7 +77,7 @@ void ctvlib::create_projections()
{
b(s,i) = A.row(i).dot(vec_recon);
}
mat_slice.resize(Ny,Ny);
mat_slice.resize(Ny,Nz);
}
}

Expand Down Expand Up @@ -121,7 +121,7 @@ void ctvlib::ART(double beta, int dyn_ind)
vec_recon += A.row(j).transpose() * a * beta;
}
mat_slice = vec_recon;
mat_slice.resize(Ny, Ny);
mat_slice.resize(Ny, Nz);
}
}

Expand Down Expand Up @@ -150,7 +150,7 @@ void ctvlib::sART(double beta, int dyn_ind)
vec_recon += A.row(j).transpose() * a * beta;
}
mat_slice = vec_recon;
mat_slice.resize(Ny, Ny);
mat_slice.resize(Ny, Nz);
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ void ctvlib::SIRT(double beta, int dyn_ind)
VectorXf vec_recon = mat_slice;
vec_recon += A.transpose() * ( b.row(s).transpose() - A * vec_recon ) * beta;
mat_slice = vec_recon;
mat_slice.resize(Ny, Ny);
mat_slice.resize(Ny, Nz);
}
}

Expand Down Expand Up @@ -256,7 +256,7 @@ void ctvlib::forwardProjection(int dyn_ind)
{
g(s,i) = A.row(i).dot(vec_recon);
}
mat_slice.resize(Ny,Ny);
mat_slice.resize(Ny,Nz);
}
}

Expand Down Expand Up @@ -427,7 +427,7 @@ void ctvlib::restart_recon()
{
for (int s = 0; s < Nslice; s++)
{
recon[s] = Mat::Zero(Ny,Ny);
recon[s] = Mat::Zero(Ny,Nz);
}
}

Expand Down
Binary file modified 3D/Utils/ctvlib.cpython-37m-darwin.so
Binary file not shown.
Loading

0 comments on commit 530de40

Please sign in to comment.