Skip to content

Commit

Permalink
append class name to S_THREAD_PARAMS to avoid compiler confusion in
Browse files Browse the repository at this point in the history
templated malloc
  • Loading branch information
Soeren Sonnenburg committed Nov 18, 2012
1 parent da63688 commit be857cd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 70 deletions.
10 changes: 5 additions & 5 deletions src/shogun/classifier/svm/SVMLight.cpp
Expand Up @@ -60,7 +60,7 @@ struct S_THREAD_PARAM_REACTIVATE_LINADD
int32_t end;
};

struct S_THREAD_PARAM
struct S_THREAD_PARAM_SVMLIGHT
{
float64_t * lin ;
float64_t* W;
Expand Down Expand Up @@ -96,7 +96,7 @@ struct S_THREAD_PARAM_KERNEL

void* CSVMLight::update_linear_component_linadd_helper(void* p)
{
S_THREAD_PARAM* params = (S_THREAD_PARAM*) p;
S_THREAD_PARAM_SVMLIGHT* params = (S_THREAD_PARAM_SVMLIGHT*) p;

int32_t jj=0, j=0 ;

Expand Down Expand Up @@ -1468,7 +1468,7 @@ void CSVMLight::update_linear_component(
for (jj=0;(j=active2dnum[jj])>=0;jj++) num_elem++ ;

pthread_t* threads = SG_MALLOC(pthread_t, parallel->get_num_threads()-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, parallel->get_num_threads()-1);
S_THREAD_PARAM_SVMLIGHT* params = SG_MALLOC(S_THREAD_PARAM_SVMLIGHT, parallel->get_num_threads()-1);
int32_t start = 0 ;
int32_t step = num_elem/parallel->get_num_threads();
int32_t end = step ;
Expand Down Expand Up @@ -1639,7 +1639,7 @@ void CSVMLight::update_linear_component_mkl_linadd(
else
{
pthread_t* threads = SG_MALLOC(pthread_t, parallel->get_num_threads()-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, parallel->get_num_threads()-1);
S_THREAD_PARAM_SVMLIGHT* params = SG_MALLOC(S_THREAD_PARAM_SVMLIGHT, parallel->get_num_threads()-1);
int32_t step= num/parallel->get_num_threads();

for (int32_t t=0; t<parallel->get_num_threads()-1; t++)
Expand Down Expand Up @@ -1670,7 +1670,7 @@ void CSVMLight::update_linear_component_mkl_linadd(

void* CSVMLight::update_linear_component_mkl_linadd_helper(void* p)
{
S_THREAD_PARAM* params = (S_THREAD_PARAM*) p;
S_THREAD_PARAM_SVMLIGHT* params = (S_THREAD_PARAM_SVMLIGHT*) p;

int32_t num_kernels=params->kernel->get_num_subkernels();

Expand Down
82 changes: 41 additions & 41 deletions src/shogun/io/streaming/InputParser.h
Expand Up @@ -521,47 +521,47 @@ template <class T> void* CInputParser<T>::main_parse_loop(void* params)
this->input_source = this_obj->input_source;

while (1)
{
pthread_mutex_lock(&examples_state_lock);
if (parsing_done)
{
pthread_mutex_unlock(&examples_state_lock);
return NULL;
}
pthread_mutex_unlock(&examples_state_lock);

pthread_testcancel();

current_example = examples_ring->get_free_example();
current_feature_vector = current_example->fv.vector;
current_len = current_example->fv.vlen;
current_label = current_example->label;

if (example_type == E_LABELLED)
get_vector_and_label(current_feature_vector, current_len, current_label);
else
get_vector_only(current_feature_vector, current_len);

if (current_len < 0)
{
pthread_mutex_lock(&examples_state_lock);
parsing_done = true;
pthread_cond_signal(&examples_state_changed);
pthread_mutex_unlock(&examples_state_lock);
return NULL;
}

current_example->label = current_label;
current_example->fv.vector = current_feature_vector;
current_example->fv.vlen = current_len;

examples_ring->copy_example(current_example);

pthread_mutex_lock(&examples_state_lock);
number_of_vectors_parsed++;
pthread_cond_signal(&examples_state_changed);
pthread_mutex_unlock(&examples_state_lock);
}
{
pthread_mutex_lock(&examples_state_lock);
if (parsing_done)
{
pthread_mutex_unlock(&examples_state_lock);
return NULL;
}
pthread_mutex_unlock(&examples_state_lock);

pthread_testcancel();

current_example = examples_ring->get_free_example();
current_feature_vector = current_example->fv.vector;
current_len = current_example->fv.vlen;
current_label = current_example->label;

if (example_type == E_LABELLED)
get_vector_and_label(current_feature_vector, current_len, current_label);
else
get_vector_only(current_feature_vector, current_len);

if (current_len < 0)
{
pthread_mutex_lock(&examples_state_lock);
parsing_done = true;
pthread_cond_signal(&examples_state_changed);
pthread_mutex_unlock(&examples_state_lock);
return NULL;
}

current_example->label = current_label;
current_example->fv.vector = current_feature_vector;
current_example->fv.vlen = current_len;

examples_ring->copy_example(current_example);

pthread_mutex_lock(&examples_state_lock);
number_of_vectors_parsed++;
pthread_cond_signal(&examples_state_changed);
pthread_mutex_unlock(&examples_state_lock);
}
#endif /* HAVE_PTHREAD */
return NULL;
}
Expand Down
14 changes: 7 additions & 7 deletions src/shogun/kernel/CombinedKernel.cpp
Expand Up @@ -27,7 +27,7 @@
using namespace shogun;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
struct S_THREAD_PARAM
struct S_THREAD_PARAM_COMBINED_KERNEL
{
CKernel* kernel;
float64_t* result;
Expand Down Expand Up @@ -368,7 +368,7 @@ void CCombinedKernel::compute_batch(

void* CCombinedKernel::compute_optimized_kernel_helper(void* p)
{
S_THREAD_PARAM* params= (S_THREAD_PARAM*) p;
S_THREAD_PARAM_COMBINED_KERNEL* params= (S_THREAD_PARAM_COMBINED_KERNEL*) p;
int32_t* vec_idx=params->vec_idx;
CKernel* k=params->kernel;
float64_t* result=params->result;
Expand All @@ -381,7 +381,7 @@ void* CCombinedKernel::compute_optimized_kernel_helper(void* p)

void* CCombinedKernel::compute_kernel_helper(void* p)
{
S_THREAD_PARAM* params= (S_THREAD_PARAM*) p;
S_THREAD_PARAM_COMBINED_KERNEL* params= (S_THREAD_PARAM_COMBINED_KERNEL*) p;
int32_t* vec_idx=params->vec_idx;
CKernel* k=params->kernel;
float64_t* result=params->result;
Expand Down Expand Up @@ -419,7 +419,7 @@ void CCombinedKernel::emulate_compute_batch(

if (num_threads < 2)
{
S_THREAD_PARAM params;
S_THREAD_PARAM_COMBINED_KERNEL params;
params.kernel=k;
params.result=result;
params.start=0;
Expand All @@ -431,7 +431,7 @@ void CCombinedKernel::emulate_compute_batch(
else
{
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, num_threads);
S_THREAD_PARAM_COMBINED_KERNEL* params = SG_MALLOC(S_THREAD_PARAM_COMBINED_KERNEL, num_threads);
int32_t step= num_vec/num_threads;

int32_t t;
Expand Down Expand Up @@ -476,7 +476,7 @@ void CCombinedKernel::emulate_compute_batch(

if (num_threads < 2)
{
S_THREAD_PARAM params;
S_THREAD_PARAM_COMBINED_KERNEL params;
params.kernel=k;
params.result=result;
params.start=0;
Expand All @@ -491,7 +491,7 @@ void CCombinedKernel::emulate_compute_batch(
else
{
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, num_threads);
S_THREAD_PARAM_COMBINED_KERNEL* params = SG_MALLOC(S_THREAD_PARAM_COMBINED_KERNEL, num_threads);
int32_t step= num_vec/num_threads;

int32_t t;
Expand Down
Expand Up @@ -31,7 +31,7 @@ using namespace shogun;
#define TRIES(X) ((use_poim_tries) ? (poim_tries.X) : (tries.X))

#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <class Trie> struct S_THREAD_PARAM
template <class Trie> struct S_THREAD_PARAM_WDS
{
int32_t* vec;
float64_t* result;
Expand Down Expand Up @@ -1171,7 +1171,7 @@ bool CWeightedDegreePositionStringKernel::init_block_weights()

void* CWeightedDegreePositionStringKernel::compute_batch_helper(void* p)
{
S_THREAD_PARAM<DNATrie>* params = (S_THREAD_PARAM<DNATrie>*) p;
S_THREAD_PARAM_WDS<DNATrie>* params = (S_THREAD_PARAM_WDS<DNATrie>*) p;
int32_t j=params->j;
CWeightedDegreePositionStringKernel* wd=params->kernel;
CTrie<DNATrie>* tries=params->tries;
Expand Down Expand Up @@ -1258,7 +1258,7 @@ void CWeightedDegreePositionStringKernel::compute_batch(
#endif
{
init_optimization(num_suppvec, IDX, alphas, j);
S_THREAD_PARAM<DNATrie> params;
S_THREAD_PARAM_WDS<DNATrie> params;
params.vec=vec;
params.result=result;
params.weights=weights;
Expand Down Expand Up @@ -1286,7 +1286,7 @@ void CWeightedDegreePositionStringKernel::compute_batch(
{
init_optimization(num_suppvec, IDX, alphas, j);
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM<DNATrie>* params = SG_MALLOC(S_THREAD_PARAM<DNATrie>, num_threads);
S_THREAD_PARAM_WDS<DNATrie>* params = SG_MALLOC(S_THREAD_PARAM_WDS<DNATrie>, num_threads);
int32_t step= num_vec/num_threads;
int32_t t;

Expand Down
8 changes: 4 additions & 4 deletions src/shogun/kernel/string/WeightedDegreeStringKernel.cpp
Expand Up @@ -28,7 +28,7 @@
using namespace shogun;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
struct S_THREAD_PARAM
struct S_THREAD_PARAM_WD
{

int32_t* vec;
Expand Down Expand Up @@ -825,7 +825,7 @@ bool CWeightedDegreeStringKernel::init_block_weights()

void* CWeightedDegreeStringKernel::compute_batch_helper(void* p)
{
S_THREAD_PARAM* params = (S_THREAD_PARAM*) p;
S_THREAD_PARAM_WD* params = (S_THREAD_PARAM_WD*) p;
int32_t j=params->j;
CWeightedDegreeStringKernel* wd=params->kernel;
CTrie<DNATrie>* tries=params->tries;
Expand Down Expand Up @@ -889,7 +889,7 @@ void CWeightedDegreeStringKernel::compute_batch(
#endif
{
init_optimization(num_suppvec, IDX, alphas, j);
S_THREAD_PARAM params;
S_THREAD_PARAM_WD params;
params.vec=vec;
params.result=result;
params.weights=weights;
Expand All @@ -914,7 +914,7 @@ void CWeightedDegreeStringKernel::compute_batch(
{
init_optimization(num_suppvec, IDX, alphas, j);
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, num_threads);
S_THREAD_PARAM_WD* params = SG_MALLOC(S_THREAD_PARAM_WD, num_threads);
int32_t step= num_vec/num_threads;
int32_t t;

Expand Down
12 changes: 6 additions & 6 deletions src/shogun/machine/KernelMachine.cpp
Expand Up @@ -18,7 +18,7 @@
using namespace shogun;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
struct S_THREAD_PARAM
struct S_THREAD_PARAM_KERNEL_MACHINE
{
CKernelMachine* kernel_machine;
float64_t* result;
Expand Down Expand Up @@ -335,7 +335,7 @@ SGVector<float64_t> CKernelMachine::apply_get_outputs(CFeatures* data)

if (num_threads < 2)
{
S_THREAD_PARAM params;
S_THREAD_PARAM_KERNEL_MACHINE params;
params.kernel_machine=this;
params.result = output.vector;
params.start=0;
Expand All @@ -349,7 +349,7 @@ SGVector<float64_t> CKernelMachine::apply_get_outputs(CFeatures* data)
else
{
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, num_threads);
S_THREAD_PARAM_KERNEL_MACHINE* params = SG_MALLOC(S_THREAD_PARAM_KERNEL_MACHINE, num_threads);
int32_t step= num_vectors/num_threads;

int32_t t;
Expand Down Expand Up @@ -420,7 +420,7 @@ float64_t CKernelMachine::apply_one(int32_t num)

void* CKernelMachine::apply_helper(void* p)
{
S_THREAD_PARAM* params = (S_THREAD_PARAM*) p;
S_THREAD_PARAM_KERNEL_MACHINE* params = (S_THREAD_PARAM_KERNEL_MACHINE*) p;
float64_t* result = params->result;
CKernelMachine* kernel_machine = params->kernel_machine;

Expand Down Expand Up @@ -550,7 +550,7 @@ SGVector<float64_t> CKernelMachine::apply_locked_get_output(

if (num_threads<2)
{
S_THREAD_PARAM params;
S_THREAD_PARAM_KERNEL_MACHINE params;
params.kernel_machine=this;
params.result=output.vector;

Expand All @@ -567,7 +567,7 @@ SGVector<float64_t> CKernelMachine::apply_locked_get_output(
else
{
pthread_t* threads = SG_MALLOC(pthread_t, num_threads-1);
S_THREAD_PARAM* params=SG_MALLOC(S_THREAD_PARAM, num_threads);
S_THREAD_PARAM_KERNEL_MACHINE* params=SG_MALLOC(S_THREAD_PARAM_KERNEL_MACHINE, num_threads);
int32_t step= num_inds/num_threads;

int32_t t;
Expand Down
6 changes: 3 additions & 3 deletions src/shogun/regression/svr/SVRLight.cpp
Expand Up @@ -38,7 +38,7 @@ extern "C" {
using namespace shogun;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
struct S_THREAD_PARAM
struct S_THREAD_PARAM_SVRLIGHT
{
float64_t* lin;
int32_t start, end;
Expand Down Expand Up @@ -361,7 +361,7 @@ float64_t CSVRLight::compute_objective_function(

void* CSVRLight::update_linear_component_linadd_helper(void *params_)
{
S_THREAD_PARAM * params = (S_THREAD_PARAM*) params_ ;
S_THREAD_PARAM_SVRLIGHT * params = (S_THREAD_PARAM_SVRLIGHT*) params_ ;

int32_t jj=0, j=0 ;

Expand Down Expand Up @@ -440,7 +440,7 @@ void CSVRLight::update_linear_component(
for(jj=0;(j=active2dnum[jj])>=0;jj++) num_elem++ ;

pthread_t* threads = SG_MALLOC(pthread_t, parallel->get_num_threads()-1);
S_THREAD_PARAM* params = SG_MALLOC(S_THREAD_PARAM, parallel->get_num_threads()-1);
S_THREAD_PARAM_SVRLIGHT* params = SG_MALLOC(S_THREAD_PARAM_SVRLIGHT, parallel->get_num_threads()-1);
int32_t start = 0 ;
int32_t step = num_elem/parallel->get_num_threads() ;
int32_t end = step ;
Expand Down

0 comments on commit be857cd

Please sign in to comment.