8000 [findpt] No more setup inside findpt_eval by yslan · Pull Request #43 · Nek5000/gslib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[findpt] No more setup inside findpt_eval #43

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

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 67 additions & 60 deletions src/findpts_imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,62 @@ void findptsms_free(struct findpts_data *fd)
free(fd);
}


struct eval_src_pt { double r[D]; uint index, proc, el; };
struct eval_out_pt { double out; uint index, proc; };

static void setup_fev_aux(
const uint *const code_base, const unsigned code_stride,
const uint *const proc_base, const unsigned proc_stride,
const uint *const el_base, const unsigned el_stride,
const double *const r_base, const unsigned r_stride,
const uint npt, struct findpts_data *const fd)
{
struct array src;
/* copy user data, weed out unfound points, send out */
{
uint index;
const uint *code=code_base, *proc=proc_base, *el=el_base;
const double *r=r_base;
struct eval_src_pt *pt;
array_init(struct eval_src_pt, &src, npt), pt=src.ptr;
for(index=0;index<npt;++index) {
if(*code!=CODE_NOT_FOUND) {
unsigned d;
for(d=0;d<D;++d) pt->r[d]=r[d];
pt->index=index;
pt->proc=*proc;
pt->el=*el;
++pt;
}
r = (const double*)((const char*)r + r_stride);
code = (const uint*)((const char*)code+code_stride);
proc = (const uint*)((const char*)proc+proc_stride);
el = (const uint*)((const char*)el + el_stride);
}
src.n = pt - (struct eval_src_pt*)src.ptr;
sarray_transfer(struct eval_src_pt,&src,proc,1,&fd->cr);
}
/* setup space for source points*/
{
uint n=src.n;
uint d;
const struct eval_src_pt *spt;
struct eval_src_pt *opt;
/* group points by element */
sarray_sort(struct eval_src_pt,src.ptr,n, el,0, &fd->cr.data);
array_init(struct eval_src_pt,&fd->savpt,n), fd->savpt.n=n;
spt=src.ptr, opt=fd->savpt.ptr;
for(;n;--n,++spt,++opt) {
opt->index= spt->index;
opt->proc = spt->proc;
opt->el = spt->el ;
for(d=0;d<D;++d) opt->r[d] = spt->r[d];
}
array_free(&src);
}
}

struct src_pt { double x[D]; uint index, proc, session_id; };
struct out_pt { double r[D], dist2, disti; uint index, code, el, proc, elsid; };

Expand Down Expand Up @@ -521,60 +577,14 @@ void findptsms( uint *const code_base, const unsigned code
}
free(distv);
free(elsidv);
}

struct eval_src_pt { double r[D]; uint index, proc, el; };
struct eval_out_pt { double out; uint index, proc; };

static void setup_fev_aux(
const uint *const code_base, const unsigned code_stride,
const uint *const proc_base, const unsigned proc_stride,
const uint *const el_base, const unsigned el_stride,
const double *const r_base, const unsigned r_stride,
const uint npt, struct findpts_data *const fd)
{
struct array src;
/* copy user data, weed out unfound points, send out */
{
uint index;
const uint *code=code_base, *proc=proc_base, *el=el_base;
const double *r=r_base;
struct eval_src_pt *pt;
array_init(struct eval_src_pt, &src, npt), pt=src.ptr;
for(index=0;index<npt;++index) {
if(*code!=CODE_NOT_FOUND) {
unsigned d;
for(d=0;d<D;++d) pt->r[d]=r[d];
pt->index=index;
pt->proc=*proc;
pt->el=*el;
++pt;
}
r = (const double*)((const char*)r + r_stride);
code = (const uint*)((const char*)code+code_stride);
proc = (const uint*)((const char*)proc+proc_stride);
el = (const uint*)((const char*)el + el_stride);
}
src.n = pt - (struct eval_src_pt*)src.ptr;
sarray_transfer(struct eval_src_pt,&src,proc,1,&fd->cr);
}
/* setup space for source points*/
{
uint n=src.n;
uint d;
const struct eval_src_pt *spt;
struct eval_src_pt *opt;
/* group points by element */
sarray_sort(struct eval_src_pt,src.ptr,n, el,0, &fd->cr.data);
array_init(struct eval_src_pt,&fd->savpt,n), fd->savpt.n=n;
spt=src.ptr, opt=fd->savpt.ptr;
for(;n;--n,++spt,++opt) {
opt->index= spt->index;
opt->proc = spt->proc;
opt->el = spt->el ;
for(d=0;d<D;++d) opt->r[d] = spt->r[d];
}
array_free(&src);

if (fd->fevsetup==0) {
setup_fev_aux(code_base,code_stride,
proc_base,proc_stride,
el_base, el_stride,
r_base, r_stride,
npt, fd);
fd->fevsetup=1;
}
}

Expand All @@ -588,13 +598,10 @@ void findptsms_eval(
const double *const in, struct findpts_data *const fd)
{
if (fd->fevsetup==0) {
setup_fev_aux(code_base,code_stride,
proc_base,proc_stride,
el_base, el_stride,
r_base, r_stride,
npt, fd);
fd->fevsetup=1;
printf("Please call findpt in advance\n");
die(1);
}

struct array outpt;
/* evaluate points, send back */
{
Expand Down
0