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

Tracking significant speed up #807

Merged
merged 5 commits into from Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/mad_elem.h
Expand Up @@ -3,6 +3,7 @@

// types
enum en_apertype{circle, ellipse, rectangle, lhcscreen, rectcircle, rectellipse, racetrack, octagon, custom};
enum track_enums{non_existing, enum_other_bv, enum_lrad, enum_noise, enum_angle, enum_time_var};
struct node;
struct name_list;
struct command;
Expand All @@ -24,6 +25,8 @@ struct element /* each element is unique */
/* *this for base_type elements (rbend etc.) */

struct aperture* aper;
double *tt_attrib;
struct multipole* multip;
};

struct aperture
Expand All @@ -35,6 +38,13 @@ struct aperture
double *ylist;
int length;
};
struct multipole
{
int nn;
int ns;
double *knl;
double *ksl;
};

struct el_list /* contains list of element pointers sorted by name */
{
Expand Down
7 changes: 7 additions & 0 deletions src/mad_extrn_f.h
Expand Up @@ -84,7 +84,13 @@
#define inside_userdefined_geometry inside_userdefined_geometry_
#define node_aperture_vector node_aperture_vector_
#define node_aperture_offset node_aperture_offset_
#define node_obs_point node_obs_point_

#define alloc_tt_attrib alloc_tt_attrib_
#define set_tt_attrib set_tt_attrib_
#define get_tt_attrib get_tt_attrib_
#define set_tt_multipoles set_tt_multipoles_
#define get_tt_multipoles get_tt_multipoles_
// from mad_option.c
#define get_option get_option_ // *
#define set_option set_option_
Expand Down Expand Up @@ -121,6 +127,7 @@

// from mad_seq.c
#define restart_sequ restart_sequ_
#define get_nnodes get_nnodes_

// from mad_table.c
// warning:augment_counts is provided by madx_ptc_knobs.f90
Expand Down
50 changes: 50 additions & 0 deletions src/mad_node.c
Expand Up @@ -327,6 +327,56 @@ node_value(const char* par)
else value = element_value(current_node, lpar);
return value;
}
double node_obs_point(void){
return current_node->obs_point;
}

void set_tt_multipoles(int *maxmul){
int tmp_n, tmp_s;
double tmp_nv[*maxmul] ;
double tmp_sv[*maxmul] ;
current_node->p_elem->multip = mycalloc("alloc mult struct", 1, sizeof (*current_node->p_elem->multip));
current_node->p_elem->multip->knl = mycalloc("alloc multip normal", *maxmul, sizeof (*current_node->p_elem->multip->knl));
current_node->p_elem->multip->ksl = mycalloc("alloc multip skew" , *maxmul, sizeof (*current_node->p_elem->multip->ksl));

get_node_vector("knl", &tmp_n, tmp_nv);
get_node_vector("ksl", &tmp_s, tmp_sv);
current_node->p_elem->multip->nn = tmp_n;
current_node->p_elem->multip->ns = tmp_s;

for(int i=0;i<tmp_n;i++){
current_node->p_elem->multip->knl[i] = tmp_nv[i];
}
for(int i=0;i<tmp_s;i++){
current_node->p_elem->multip->ksl[i] = tmp_sv[i];
}


}

void get_tt_multipoles(int *nn, double *knl, int *ns, double *ksl){
nn[0]=current_node->p_elem->multip->nn;
ns[0]=current_node->p_elem->multip->ns;
for(int i=0;i<*nn;i++){
knl[i] = current_node->p_elem->multip->knl[i];
}
for(int i=0;i<*ns;i++){
ksl[i] = current_node->p_elem->multip->ksl[i];
}


}
void alloc_tt_attrib(int *length){
current_node->p_elem->tt_attrib = mycalloc("tmp_array_tt", (*length+1), sizeof (*current_node->p_elem->tt_attrib));
}

void set_tt_attrib(int *index, double *value){
current_node->p_elem->tt_attrib[*index] = *value;
}

double get_tt_attrib(int *index){
return current_node->p_elem->tt_attrib[*index];
}

void
link_in_front(struct node* new, struct node* el)
Expand Down
6 changes: 6 additions & 0 deletions src/mad_node.h
Expand Up @@ -108,6 +108,12 @@ int inside_userdefined_geometry(double *x, double *y);
double get_length_(void);
void node_aperture_vector(double * vec);
void node_aperture_offset(double * vec);
void alloc_tt_attrib(int *length);
void set_tt_attrib(int *index, double *value);
double get_tt_attrib(int *index);
void set_tt_multipoles(int *maxmul);
void get_tt_multipoles(int *nn, double *knl, int *ns, double *ksl);
double node_obs_point(void);

#endif // MAD_NODE_H

4 changes: 4 additions & 0 deletions src/mad_seq.c
Expand Up @@ -2083,6 +2083,10 @@ expand_curr_sequ(int flag)
}
}

int get_nnodes(void){
return current_sequ->n_nodes;
}

void
reset_errors(struct sequence* sequ)
/* zeros the sel_err node flag for all nodes of an expanded sequence */
Expand Down
1 change: 1 addition & 0 deletions src/mad_seq.h
Expand Up @@ -92,6 +92,7 @@ int set_enable(const char* type, struct in_cmd*);
void set_sequence(char* name);
int set_cont_sequence(void);
int sequ_check_valid_twiss(struct sequence*);
int get_nnodes(void);

#endif // MAD_SEQ_H

4 changes: 3 additions & 1 deletion src/mad_track.c
Expand Up @@ -94,9 +94,11 @@ track_run(struct in_cmd* cmd)
buf4 = mymalloc_atomic(rout_name, 36 * sizeof *buf4);
buf6 = mymalloc_atomic(rout_name, nnode * sizeof *buf6);


// run track rountine
trrun_(&flag, &turns,orbit0, oneturnmat, ibuf1, ibuf2, buf1, buf2,
buf_dxt, buf_dyt, buf3, buf4, &buf5, &e_flag, ibuf3, buf6);
buf_dxt, buf_dyt, buf3, buf4, &buf5, &e_flag, ibuf3,
buf6);

// summary
t = find_table("tracksumm");
Expand Down