-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
176 additions
and
21 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
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
19 changes: 19 additions & 0 deletions
19
sources/jvxLibraries/jvx-dsp-base/include/jvx_profiler/jvx_profiler_data_entry.h
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,19 @@ | ||
#ifndef __JVX_PROFILER_DATA_ENTRY_H__ | ||
#define __JVX_PROFILER_DATA_ENTRY_H__ | ||
|
||
#include "jvx_dsp_base.h" | ||
|
||
struct jvx_profiler_data_entry | ||
{ | ||
jvxSize sz; | ||
jvxHandle* fld; | ||
jvxCBool cplx; | ||
}; | ||
|
||
typedef jvxErrorType(*jvx_register_entry_profiling_data_c)(struct jvx_profiler_data_entry* dat, const char* name, jvxHandle* inst); | ||
typedef jvxErrorType(*jvx_unregister_entry_profiling_data_c)(const char* name, jvxHandle* inst); | ||
|
||
void jvx_profiler_allocate_single_entry(struct jvx_profiler_data_entry* entry, jvxSize szFld, jvxCBool cplxFld); | ||
void jvx_profiler_deallocate_single_entry(struct jvx_profiler_data_entry* entry); | ||
|
||
#endif |
23 changes: 23 additions & 0 deletions
23
sources/jvxLibraries/jvx-dsp-base/src/jvx_profiler/jvx_profiler_data_entry.c
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 @@ | ||
#include "jvx_profiler/jvx_profiler_data_entry.h" | ||
|
||
void jvx_profiler_allocate_single_entry(struct jvx_profiler_data_entry* entry, jvxSize szFld, jvxCBool cplxFld) | ||
{ | ||
entry->sz = szFld; | ||
entry->cplx = cplxFld; | ||
assert(entry->fld == NULL); | ||
if (entry->cplx) | ||
{ | ||
JVX_DSP_SAFE_ALLOCATE_FIELD_Z(entry->fld, jvxDataCplx, entry->sz); | ||
} | ||
else | ||
{ | ||
JVX_DSP_SAFE_ALLOCATE_FIELD_Z(entry->fld, jvxData, entry->sz); | ||
} | ||
} | ||
|
||
void jvx_profiler_deallocate_single_entry(struct jvx_profiler_data_entry* entry) | ||
{ | ||
JVX_DSP_SAFE_DELETE_FIELD(entry->fld); | ||
entry->sz = 0; | ||
entry->cplx = false; | ||
} |
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
13 changes: 13 additions & 0 deletions
13
sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsMin.h
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 @@ | ||
/** | ||
* Class to share external call handler instance between component and core mexcall handler | ||
*///=============================================================================== | ||
|
||
class CjvxMexCallsMin | ||
{ | ||
public: | ||
// Reference to matlab call handler to be used throughout the components life time | ||
// Shared between inernal and external use | ||
IjvxExternalCall* _theExtCallHandler = nullptr; | ||
std::string _theExtCallObjectName; | ||
|
||
}; |
22 changes: 22 additions & 0 deletions
22
sources/jvxLibraries/jvxLexternalCall/include/CjvxMexCallsProfiler.h
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,22 @@ | ||
#ifndef __CJVXMEXCALLSPROFILER__H__ | ||
#define __CJVXMEXCALLSPROFILER__H__ | ||
|
||
#include "jvx.h" | ||
#include "CjvxMexCallsMin.h" | ||
|
||
#include "jvx_profiler/jvx_profiler_data_entry.h" | ||
|
||
class CjvxMexCallsProfiler: public CjvxMexCallsMin | ||
{ | ||
protected: | ||
std::string varNameHdlMatlab = "hdl_profile_data"; | ||
public: | ||
std::map<std::string, jvx_profiler_data_entry*> registeredProfilerData; | ||
jvxErrorType register_profiling_data(jvx_profiler_data_entry*, const std::string& nm); | ||
jvxErrorType unregister_profiling_data(const std::string& nm); | ||
jvxErrorType provideDataMexCall(); | ||
static jvxErrorType jvx_register_entry_profiling_data_cb(jvx_profiler_data_entry* dat, const char* name, jvxHandle* inst); | ||
static jvxErrorType jvx_unregister_entry_profiling_data_cb(const char* name, jvxHandle* inst); | ||
}; | ||
|
||
#endif |
86 changes: 86 additions & 0 deletions
86
sources/jvxLibraries/jvxLexternalCall/src/CjvxMexCallsProfiler.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,86 @@ | ||
#include "CjvxMexCallsProfiler.h" | ||
|
||
#define AYF_COPY_TPX(fld, sz, nm, cplx) \ | ||
|
||
|
||
#define AYF_COPY_TPX_STR(entry, nm) \ | ||
AYF_COPY_TPX(entry->fld, entry->sz, nm, entry.cplx) | ||
|
||
jvxErrorType | ||
CjvxMexCallsProfiler::register_profiling_data(jvx_profiler_data_entry * data, const std::string& nm) | ||
{ | ||
auto elm = registeredProfilerData.find(nm); | ||
if (elm == registeredProfilerData.end()) | ||
{ | ||
registeredProfilerData[nm] = data; | ||
return JVX_NO_ERROR; | ||
} | ||
return JVX_ERROR_DUPLICATE_ENTRY; | ||
} | ||
|
||
jvxErrorType | ||
CjvxMexCallsProfiler::unregister_profiling_data(const std::string& nm) | ||
{ | ||
auto elm = registeredProfilerData.find(nm); | ||
if (elm != registeredProfilerData.end()) | ||
{ | ||
registeredProfilerData.erase(elm); | ||
return JVX_NO_ERROR; | ||
} | ||
return JVX_ERROR_ELEMENT_NOT_FOUND; | ||
} | ||
|
||
jvxErrorType | ||
CjvxMexCallsProfiler::provideDataMexCall() | ||
{ | ||
jvxExternalDataType* passToMatlab = NULL; | ||
for (auto& elm : registeredProfilerData) | ||
{ | ||
if (elm.second->fld) | ||
{ | ||
_theExtCallHandler->convertCToExternal(&passToMatlab, elm.second->fld, | ||
elm.second->sz, JVX_DATAFORMAT_DATA, elm.second->cplx); | ||
if (passToMatlab) | ||
{ | ||
_theExtCallHandler->putVariableToExternal("caller", elm.first.c_str(), passToMatlab); | ||
std::string command = "global " + varNameHdlMatlab + "; " + varNameHdlMatlab + ".tp."; | ||
command += elm.first; | ||
command += " = "; | ||
command += elm.first; | ||
command += ";"; | ||
jvxErrorType resCommand = _theExtCallHandler->executeExternalCommand(command.c_str()); | ||
if (resCommand != JVX_NO_ERROR) | ||
{ | ||
jvxApiString astr; | ||
_theExtCallHandler->getLastErrorReason(&astr); | ||
_theExtCallHandler->postMessageExternal(("Last operation <" + command + "> failed, reason: <" + astr.std_str() + ">.").c_str(), true); | ||
} | ||
} | ||
} | ||
} | ||
return JVX_NO_ERROR; | ||
} | ||
|
||
jvxErrorType | ||
CjvxMexCallsProfiler::jvx_register_entry_profiling_data_cb(jvx_profiler_data_entry* dat, const char* name, jvxHandle* inst) | ||
{ | ||
if (inst) | ||
{ | ||
CjvxMexCallsProfiler* this_pointer = (CjvxMexCallsProfiler*)inst; | ||
return this_pointer->register_profiling_data(dat, name); | ||
} | ||
return JVX_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
jvxErrorType | ||
CjvxMexCallsProfiler::jvx_unregister_entry_profiling_data_cb(const char* name, jvxHandle* inst) | ||
{ | ||
if (inst) | ||
{ | ||
CjvxMexCallsProfiler* this_pointer = (CjvxMexCallsProfiler*)inst; | ||
return this_pointer->unregister_profiling_data(name); | ||
} | ||
return JVX_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
|