static void compute_sum_dcov_thread(int ni,int ki,int di, const float *v,const float *mu_old,const float *p, float *mu,float *sigma,float *w, int n_thread) { long n=ni,d=di,k=ki; compute_sum_dcov_t t= { n,k,d, v,mu_old,p, fvec_new(n_thread*d*k), /* mu */ fvec_new(n_thread*d*k), /* sigma */ fvec_new(n_thread*k), /* w */ n_thread }; compute_tasks(n_thread,n_thread,&compute_sum_dcov_task_fun,&t); /* accumulate over n's */ long i; fvec_cpy(mu,t.mu,k*d); fvec_cpy(sigma,t.sigma,k*d); fvec_cpy(w,t.w,k); for(i=1; i<n_thread; i++) { fvec_add(mu,t.mu+i*d*k,d*k); fvec_add(sigma,t.sigma+i*d*k,d*k); fvec_add(w,t.w+i*k,k); } free(t.mu); free(t.sigma); free(t.w); }
void gmm_compute_p_thread (int n, const float * v, const gmm_t * g, float * p, int do_norm, int n_thread) { compute_p_params_t t= {n,v,g,p,do_norm,n_thread}; compute_tasks(n_thread,n_thread,&compute_p_task_fun,&t); }
void compute_cross_distances_alt_thread (int distance_type,int d, int na, int nb, const float *a, const float *b, float *dist2, int nt) { cross_distances_params_t t = {distance_type,d,na,nb,a,b,dist2,nt}; int n=MAX(na,nb); if(n<nt) /* too small, no threads */ compute_cross_distances_alt (distance_type,d,na,nb,a,b,dist2); else { t.split_a=na>nb; compute_tasks(nt,nt,&compute_cross_distances_task,&t); } }
void knn_full_thread (int distance_type, int npt, int nclust, int d, int k, const float *codebook, const float *coords, const float *vw_weights, int *vw, float *vwdis2, int n_thread) { if (npt < n_thread || n_thread == 1) { /* too few pts */ return knn_full (distance_type, npt, nclust, d, k, codebook, coords, vw_weights, vw, vwdis2); } nn_input_t task = { distance_type, nclust, d, k, codebook, npt, coords, vw_weights, vw, vwdis2, n_thread }; compute_tasks (n_thread, n_thread, &nn_task, &task); }