-
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.
Added support for mex wrapper for prepare A matrix
- Loading branch information
Showing
4 changed files
with
163 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 @@ | ||
% 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 ... | ||
prepare_a_matrix_mex.cu ../src/prepare_a_matrix.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "../src/prepare_a_matrix.h" // include the header | ||
#include "mex.h" | ||
|
||
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { | ||
if (nrhs != 5) { | ||
mexErrMsgIdAndTxt("beamformer_mex:InvalidInput", | ||
"Five inputs required: a_matrix_in, a_matrix_out, pixels, samples, device_id"); | ||
} | ||
|
||
// Extract arguments from MATLAB inputs | ||
char *a_matrix_in_c = mxArrayToString(prhs[0]); | ||
char *a_matrix_out_c = mxArrayToString(prhs[1]); | ||
double pixels_d = mxGetScalar(prhs[2]); | ||
double samples_d = mxGetScalar(prhs[3]); | ||
double device_id_d = mxGetScalar(prhs[4]); | ||
|
||
std::string a_matrix_in(a_matrix_in_c); | ||
std::string a_matrix_out(a_matrix_out_c); | ||
size_t pixels = static_cast<size_t>(pixels_d); | ||
size_t samples = static_cast<size_t>(samples_d); | ||
unsigned device_id = static_cast<unsigned>(device_id_d); | ||
|
||
mxFree(a_matrix_in_c); | ||
mxFree(a_matrix_out_c); | ||
|
||
int status = prepareAMatrix(a_matrix_in, a_matrix_out, pixels, samples, device_id); | ||
|
||
if (nlhs > 0) { | ||
plhs[0] = mxCreateDoubleScalar(static_cast<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
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,13 @@ | ||
#ifndef PREPARE_A_MATRIX_H | ||
#define PREPARE_A_MATRIX_H | ||
|
||
#include <string> | ||
#include <cstddef> // for size_t | ||
|
||
int prepareAMatrix(const std::string &path_a_matrix_in, | ||
const std::string &path_a_matrix_out, | ||
size_t pixels, | ||
size_t samples, | ||
unsigned device_id); | ||
|
||
#endif // PREPARE_A_MATRIX_H |