Skip to content
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

Conversation

shubham808
Copy link
Contributor

Fixes #4074
WIP
Please review this and guide me further.

Copy link
Member

@karlnapf karlnapf left a 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;
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

@karlnapf karlnapf left a 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

@karlnapf
Copy link
Member

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()
Copy link
Member

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
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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
Copy link
Member

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
Copy link
Member

@karlnapf karlnapf Jan 20, 2018

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
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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();
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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");
Copy link
Member

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
Copy link
Member

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

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Member

@karlnapf karlnapf left a 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

@shubham808
Copy link
Contributor Author

shubham808 commented Jan 20, 2018

@karlnapf i have removed all classes in logdet/computation too because they wont be needed if we use the new solve methods like i have... is that okay ?

@karlnapf
Copy link
Member

Yes, but pls send that in a sep. PR that includes only deletions

@shubham808 shubham808 mentioned this pull request Jan 22, 2018
@shubham808
Copy link
Contributor Author

@karlnapf we should close this one since everything related to it is already addressed elsewhere. :)

@shubham808 shubham808 closed this Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants