-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix compilation, add mex for beamforming
- Loading branch information
Showing
3 changed files
with
51 additions
and
7 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,38 @@ | ||
#include "tcbf.h" // include the header | ||
#include "mex.h" | ||
|
||
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { | ||
if (nrhs != 7) { | ||
mexErrMsgIdAndTxt("beamform:InvalidInput", | ||
"Seven inputs required: a_matrix, rf, bf, pixels, frames, samples, device_id"); | ||
} | ||
|
||
std::string path_a_matrix = mxArrayToString(prhs[0]); | ||
std::string path_rf = mxArrayToString(prhs[1]); | ||
std::string path_bf = mxArrayToString(prhs[2]); | ||
size_t pixels = mxGetScalar(prhs[3]); | ||
size_t frames = mxGetScalar(prhs[4]); | ||
size_t samples = mxGetScalar(prhs[5]); | ||
unsigned device_id = mxGetScalar(prhs[6]); | ||
|
||
cu::init(); | ||
cu::Device device(device_id); | ||
cu::Context context(CU_CTX_BLOCKING_SYNC, device); | ||
cu::Stream stream; | ||
|
||
tcbf::Beamformer beamformer(pixels, frames, samples, device, stream); | ||
cu::HostMemory RF(2 * frames * samples); | ||
cu::HostMemory BF(2 * pixels * frames * sizeof(unsigned)); | ||
|
||
beamformer.read_A_matrix(path_a_matrix); | ||
beamformer.read_RF(RF, path_rf); | ||
beamformer.process(RF, BF); | ||
beamformer.write_BF(BF, path_bf); | ||
|
||
|
||
int status = 0; | ||
|
||
if (nlhs > 0) { | ||
plhs[0] = mxCreateDoubleScalar((double)status); | ||
} | ||
} |
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,8 @@ | ||
% mex_compile_prepare_a_matrix.m | ||
% Adjust include and library paths as needed | ||
mexcuda -v ... | ||
-L"/usr/local/cuda/lib64" -lcudart -lcuda ... | ||
'NVCCFLAGS=-gencode=arch=compute_89,code=sm_89' ... | ||
-ltcbf -lccglib ... | ||
beamform_mex.cu | ||
|
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
% mex_compile_prepare_a_matrix.m | ||
% Adjust include and library paths as needed | ||
mexcuda ... | ||
-I'../include' ... % for tcbf.h if needed | ||
-I'../src' ... % for prepare_a_matrix.h | ||
-I'/path/to/ccglib/include' ... | ||
-I'/path/to/cxxopts/include' ... | ||
-L'/path/to/ccglib/lib' -lccglib ... | ||
-L'/path/to/cuda/lib64' -lcudart -lcuda ... | ||
mexcuda -v ... | ||
-L"/usr/local/cuda/lib64" -lcudart -lcuda ... | ||
'NVCCFLAGS=-gencode=arch=compute_89,code=sm_89' ... | ||
-lccglib ... | ||
prepare_a_matrix_mex.cu ../src/prepare_a_matrix.cu | ||
|