New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deleting and testing #4092
deleting and testing #4092
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big and scary PR.
Let's try to make it a bit smaller:
1.) Only the modifications to not use the computation
classes anymore, including your openmp changes
2.) Only deleting files
It should be quite straightforward to pull out the changes from here and open another PR with them. Leave this one here open and re-base it later once the other one is merged. I will comment inline on what parts I'd like to review separately
// for storing the aggregators that submit_jobs return | ||
CDynamicObjectArray* aggregators=new CDynamicObjectArray(); | ||
// for storing the result | ||
CDynamicArray<float64_t> aggregators; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either use Std::vector,or (since you know the size in advance) sgvector
* | ||
* Written (W) 2013 Soumyajit De |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to not see these changes in the PR. They are unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to rebase against the latest develop version. There are a lot of files shown here that were changed by someone else
The rebase needs to happen before I can review anything. This is just too big |
@@ -50,16 +49,13 @@ def mathematics_logdet (matrix=mtx,max_iter_eig=1000,max_iter_lin=1000,num_sampl | |||
lin_solver=CGMShiftedFamilySolver() | |||
lin_solver.set_iteration_limit(max_iter_lin) | |||
|
|||
# computation engine | |||
engine=SerialComputationEngine() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of a change that should be in the other PR, as it changes usage of the rational approx framework
%rename (JobResult) CJobResult; | ||
%include <shogun/lib/computation/jobresult/JobResult.h> | ||
%include <shogun/lib/computation/jobresult/ScalarResult.h> | ||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have some serious git issues in here ;)
Need to read on how to rebase and how all of git works really. Never commit merge conflicts into a PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I did make a lot mistakes sorry about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries at all. Next time, just make sure to have a look at the diff of your PR in github yourself before you press "send".
#ifdef USE_INT32 | ||
%template(ScalarIntResult) CScalarResult<int32_t>; | ||
#endif | ||
#ifdef USE_UINT32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can come in a second patch
index_t num_trace_samples=m_trace_sampler->get_num_samples(); | ||
|
||
for (index_t i=0; i<num_estimates; ++i) | ||
// for omp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great that you use omp here.
Pull this out into the separate patch then I can review it smoothly
|
||
#ifdef WIN32 // HAVE WIN32 | ||
for (int32_t vec = start; vec < end; vec++) | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the purpose of this contraption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case if openmp is not supported this will work like a serial implementation i found a similar thing at shogun shogun/features/DotFeatures.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better would be to look at something like this:
https://github.com/shogun-toolbox/shogun/blob/develop/src/shogun/regression/LeastAngleRegression.cpp#L251
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.... this is easier i will use that for sure.
#ifdef HAVE_OPENMP // HAVE OPENMP | ||
#pragma omp single | ||
{ | ||
num_threads = omp_get_num_threads(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use CParallel
aggregators->append_element(agg); | ||
SG_UNREF(agg); | ||
// get the trace sampler vector | ||
SGVector<float64_t> s = m_trace_sampler->sample(j); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this method thread-safe (const)?
// get the trace sampler vector | ||
SGVector<float64_t> s = m_trace_sampler->sample(j); | ||
// calculate the result for sample s | ||
float64_t agg = m_operator_log->solve(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thread safety
float64_t agg = m_operator_log->solve(s); | ||
#pragma omp critical // so that the dynamic array stays concurrent | ||
{ | ||
aggregators.append_element(agg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely not thread safe. But if you use a vector as mentioned above, this should be ok
m_computation_engine->wait_for_all(); | ||
SG_INFO("All jobs finished, aggregating results\n"); | ||
// wait for all the computations to be completed | ||
SG_INFO("Waiting for computations to finish\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to have that comment
SG_INFO("All jobs finished, aggregating results\n"); | ||
// wait for all the computations to be completed | ||
SG_INFO("Waiting for computations to finish\n"); | ||
#pragma omp barrier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think you need barriers. The loop is simple and you can just use #pragma omp parallel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried parallel but didnt do the trick maybe i will try again
|
||
// iterate through indices, group results in the same way as jobs | ||
samples[idx_col]+=r->get_result(); | ||
samples[idx_col] += aggregators.get_element(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you remove the aggregators
variable and directly store in samples
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will use samples directly in the next patch
// for storing the aggregators that submit_jobs return | ||
CDynamicObjectArray aggregators; | ||
index_t num_trace_samples=m_trace_sampler->get_num_samples(); | ||
// for storing the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is so much overlapping code here. Could we maybe refactor this to avoid that?
@lambday what are your thoughts here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more initial feedback on the files that matter in the first PR
@karlnapf i have removed all classes in |
Yes, but pls send that in a sep. PR that includes only deletions |
@karlnapf we should close this one since everything related to it is already addressed elsewhere. :) |
Fixes #4074
WIP
Please review this and guide me further.