-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jtschwar/multi_modal
Fused Multi Modal Tomography
- Loading branch information
Showing
29 changed files
with
3,702 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"files.associations": { | ||
"variant": "cpp", | ||
"chrono": "cpp", | ||
"__tuple": "cpp", | ||
"tuple": "cpp", | ||
"array": "cpp", | ||
"vector": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#Makefile | ||
#!/bin/sh | ||
include ./make.inc | ||
|
||
GPUCONFIG = astra_ctvlib`python3-config --extension-suffix` | ||
MMGPUCONFIG = mm_astra`python3-config --extension-suffix` | ||
MPIGPUCONFIG = mpi_astra_ctvlib`python3-config --extension-suffix` | ||
MMTVCONFIG = MM_tv`python3-config --extension-suffix` | ||
|
||
all: shared_library mm_astra | ||
|
||
shared_library: | ||
cd container; make; cd .. | ||
cd regularizers; make; cd .. | ||
nvcc -shared container/*.o regularizers/*.o -o aux_func.so | ||
|
||
mm_astra: mm_astra.cpp mm_astra.hpp | ||
$(CXX) $(CXXFLAGS) $(EIGEN) $(ASTRA) $(CUDA) $(NonPAR_HDF5_INC) mm_astra.cpp -o $(MMGPUCONFIG) $(ASTRA_LIB) aux_func.so | ||
|
||
clean: | ||
rm -rf *.so *.o | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#Makefile | ||
#!/bin/sh | ||
|
||
include ./make.inc | ||
|
||
all: matrix_op matrix3d matrix4d | ||
|
||
matrix_op: matrix_ops.cu matrix_ops.h | ||
$(CUDAXX) matrix_ops.cu | ||
|
||
matrix4d: Matrix4D.o Matrix4D.h | ||
$(CXX) $(CXXFLAGS) Matrix4D.cpp matrix_ops.o | ||
|
||
clean: | ||
rm -rf *.so *.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#include "Matrix4D.h" | ||
#include "matrix_ops.h" | ||
#include <Eigen/Core> | ||
|
||
using namespace Eigen; | ||
|
||
typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Mat; | ||
|
||
Matrix4D::Matrix4D() | ||
{ | ||
} | ||
|
||
Matrix4D::Matrix4D(int Nel, int Nx, int Ny, int Nz) { | ||
nx = Nx; | ||
ny = Ny; | ||
nz = Nz; | ||
nel = Nel; | ||
data = new float [nx*ny*nz*Nel]; | ||
volSize = nx * ny * nz; | ||
} | ||
|
||
// for (int e=0; e<nel; e++) { | ||
// for (int i=0; i<nx; i++) { | ||
// for (int j=0; j<ny; j++) { | ||
// for (int k=0; k<nz; k++) | ||
// } | ||
// } | ||
// } | ||
|
||
float Matrix4D::get_val(int e, int i, int j, int k) { | ||
return data[e*(nx*ny*nz) + (ny*nz)*i + nz*j + k]; | ||
} | ||
|
||
int Matrix4D::index(int e, int i, int j, int k){ | ||
return e*(nx*ny*nz) + (ny*nz)*i + nz*j + k; | ||
} | ||
|
||
void Matrix4D::positivity() { | ||
cuda_positivity_4D(data,nx,ny,nz,nel); | ||
} | ||
|
||
void Matrix4D::setData2D(Mat inBuffer, int element, int slice) { | ||
for (int yInd = 0; yInd < ny; yInd++) { | ||
for (int zInd = 0; zInd < nz; zInd++) { | ||
data[index(element,slice,yInd,zInd)] = inBuffer(yInd,zInd); | ||
} | ||
} | ||
} | ||
|
||
void Matrix4D::setData1D(Vec inBuffer, int element, int slice) { | ||
int ind = 0; | ||
for (int yInd = 0; yInd < ny; yInd++) { | ||
for (int zInd = 0; zInd < nz; zInd++) { | ||
ind = zInd + yInd * nz; | ||
data[index(element,slice,yInd,zInd)] = inBuffer(ind); | ||
} | ||
} | ||
} | ||
|
||
// Return Reconstruction to Python. | ||
Mat Matrix4D::getData2D(int element, int slice) { | ||
Mat outBuffer(ny,nz); | ||
for (int yInd = 0; yInd < ny; yInd++) { | ||
for (int zInd = 0; zInd < nz; zInd++) { | ||
outBuffer(yInd,zInd) = data[index(element,slice,yInd,zInd)]; | ||
} | ||
} | ||
return outBuffer; | ||
} | ||
|
||
// Vec Matrix4D::getData1D(int element, int slice) | ||
// { | ||
// int ind = 0; | ||
// Vec outBuffer(ny*nz); | ||
// for (int yInd = 0; yInd < ny; yInd++) { | ||
// for (int zInd = 0; zInd < nz; zInd++) { | ||
// ind = zInd + yInd * nz; | ||
// outBuffer[ind] = data[index(element,slice,yInd,zInd)]; | ||
// } | ||
// } | ||
// return outBuffer; | ||
// } | ||
|
||
|
||
float *Matrix4D::getData1D(int element, int slice) { | ||
int ind = 0; | ||
// Vec outBuffer(ny*nz); | ||
float *outBuffer[ny*nz]; | ||
for (int yInd = 0; yInd < ny; yInd++) { | ||
for (int zInd = 0; zInd < nz; zInd++) { | ||
ind = zInd + yInd * nz; | ||
outBuffer[ind] = &data[index(element,slice,yInd,zInd)]; | ||
} | ||
} | ||
return *outBuffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef matrix_4d_hpp | ||
#define matrix_4d_hpp | ||
|
||
#include <Eigen/Core> | ||
|
||
class Matrix4D | ||
{ | ||
|
||
typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Mat; | ||
typedef Eigen::VectorXf Vec; | ||
|
||
public: | ||
|
||
int nx, ny, nz, nel, volSize; | ||
int gpuIndex = -1; | ||
|
||
float *data; | ||
|
||
// Constructors | ||
Matrix4D(); | ||
Matrix4D(int nel, int Nx, int Ny, int Nz); | ||
|
||
// Setter Functions | ||
void setData1D(Vec inBuffer, int element, int slice); | ||
void setData2D(Mat inBuffer, int element, int slice); | ||
|
||
// Getter Functions | ||
float *getData1D(int element, int slice); | ||
Mat getData2D(int element, int slice); | ||
|
||
// Access Data | ||
float get_val(int e, int i,int j,int k); | ||
|
||
// Calculate Index | ||
int index(int e, int i, int j, int k); | ||
|
||
void positivity(); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CXX = g++ -fPIC -shared | ||
MPXX = mpicxx -fPIC -fopenmp | ||
CUDAXX = nvcc -shared -Xcompiler -fPIC -c | ||
CXXFLAGS = -O3 -Wno-div-by-zero -std=c++17 -I ../../thirdparty/eigen | ||
|
Oops, something went wrong.