Skip to content

Commit

Permalink
Added a "phase" argument to decide on when to copy the data from C to…
Browse files Browse the repository at this point in the history
… Matlab in c-code data profiling code
  • Loading branch information
hkbinaurics committed Jan 22, 2025
1 parent 155573a commit 1b44cc2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct jvx_profiler_data_entry
jvxHandle* fld;
jvxCBool cplx;
jvxCBool c_to_matlab;
jvxSize phase;
jvxCBool valid_content;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ void jvx_profiler_allocate_single_entry(struct jvx_profiler_data_entry* entry, j
entry->cplx = cplxFld;
entry->c_to_matlab = c_true;
entry->valid_content = c_true;
entry->phase = 1;
assert(entry->fld == NULL);
if (entry->cplx)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class CjvxMexCallsProfileTpl : public CjvxMexCallsTpl<T>, public CjvxMexCallsPro
jvxData* ptrTo = (jvxData*)buffers_in[i];
memcpy(ptrTo, ptrFrom, sizeof(jvxData) * this->_common_set_icon.theData_in->con_params.buffersize);
}
if (engaged)
{
// Providing data only if c code is operated
CjvxMexCallsProfiler::obtainProvideDataMexCall(true, 0);
}
}
}

Expand All @@ -183,7 +188,7 @@ class CjvxMexCallsProfileTpl : public CjvxMexCallsTpl<T>, public CjvxMexCallsPro
if (engaged)
{
// Providing data only if c code is operated
CjvxMexCallsProfiler::obtainProvideDataMexCall(false);
CjvxMexCallsProfiler::obtainProvideDataMexCall(false, 1);
}

// Run core algorithm in C
Expand All @@ -192,7 +197,7 @@ class CjvxMexCallsProfileTpl : public CjvxMexCallsTpl<T>, public CjvxMexCallsPro
if (engaged)
{
// Providing data only if c code is operated
CjvxMexCallsProfiler::obtainProvideDataMexCall(true);
CjvxMexCallsProfiler::obtainProvideDataMexCall(true, 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CjvxMexCallsProfiler: public CjvxMexCallsMin
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 obtainProvideDataMexCall(jvxBool postRun = true);
jvxErrorType obtainProvideDataMexCall(jvxBool postRun = true, jvxSize phase = 1);
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CjvxMexCallsProfiler::unregister_profiling_data(const std::string& nm)
}

jvxErrorType
CjvxMexCallsProfiler::obtainProvideDataMexCall(jvxBool provideData)
CjvxMexCallsProfiler::obtainProvideDataMexCall(jvxBool provideData, jvxSize phase)
{
jvxExternalDataType* passToMatlab = NULL;
jvxExternalDataType* passFromMatlab = NULL;
Expand Down Expand Up @@ -60,7 +60,7 @@ CjvxMexCallsProfiler::obtainProvideDataMexCall(jvxBool provideData)
}
}
}
if (!provideData && !elm.second->c_to_matlab)
if (!provideData && !elm.second->c_to_matlab && (elm.second->phase == phase))
{
std::string command = "global " + varNameHdlMatlab + "; ";
command += elm.first;
Expand Down

0 comments on commit 1b44cc2

Please sign in to comment.