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

Clarified names of existing implementations of Model base class #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions src/contraction/ctr_tsr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ namespace CTF_int {
int64_t seq_tsr_ctr::mem_fp(){ return 0; }

//double seq_tsr_ctr_mig[] = {1e-6, 9.30e-11, 5.61e-10};
LinModel<3> seq_tsr_ctr_mdl_cst(seq_tsr_ctr_mdl_cst_init,"seq_tsr_ctr_mdl_cst");
LinModel<3> seq_tsr_ctr_mdl_ref(seq_tsr_ctr_mdl_ref_init,"seq_tsr_ctr_mdl_ref");
LinModel<3> seq_tsr_ctr_mdl_inr(seq_tsr_ctr_mdl_inr_init,"seq_tsr_ctr_mdl_inr");
LinModel<3> seq_tsr_ctr_mdl_off(seq_tsr_ctr_mdl_off_init,"seq_tsr_ctr_mdl_off");
LinModel<3> seq_tsr_ctr_mdl_cst_inr(seq_tsr_ctr_mdl_cst_inr_init,"seq_tsr_ctr_mdl_cst_inr");
LinModel<3> seq_tsr_ctr_mdl_cst_off(seq_tsr_ctr_mdl_cst_off_init,"seq_tsr_ctr_mdl_cst_off");
GlobalCostModel<3> seq_tsr_ctr_mdl_cst(seq_tsr_ctr_mdl_cst_init,"seq_tsr_ctr_mdl_cst");
GlobalCostModel<3> seq_tsr_ctr_mdl_ref(seq_tsr_ctr_mdl_ref_init,"seq_tsr_ctr_mdl_ref");
GlobalCostModel<3> seq_tsr_ctr_mdl_inr(seq_tsr_ctr_mdl_inr_init,"seq_tsr_ctr_mdl_inr");
GlobalCostModel<3> seq_tsr_ctr_mdl_off(seq_tsr_ctr_mdl_off_init,"seq_tsr_ctr_mdl_off");
GlobalCostModel<3> seq_tsr_ctr_mdl_cst_inr(seq_tsr_ctr_mdl_cst_inr_init,"seq_tsr_ctr_mdl_cst_inr");
GlobalCostModel<3> seq_tsr_ctr_mdl_cst_off(seq_tsr_ctr_mdl_cst_off_init,"seq_tsr_ctr_mdl_cst_off");

uint64_t seq_tsr_ctr::est_membw(){
uint64_t size_A = sy_packed_size(order_A, edge_len_A, sym_A)*sr_A->el_size;
Expand Down
38 changes: 19 additions & 19 deletions src/contraction/spctr_tsr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,24 @@ namespace CTF_int {
return size_A+size_B+size_C;
}

LinModel<3> seq_tsr_spctr_cst_off_k0(seq_tsr_spctr_cst_off_k0_init,"seq_tsr_spctr_cst_off_k0");
LinModel<3> seq_tsr_spctr_cst_off_k1(seq_tsr_spctr_cst_off_k1_init,"seq_tsr_spctr_cst_off_k1");
LinModel<3> seq_tsr_spctr_cst_off_k2(seq_tsr_spctr_cst_off_k2_init,"seq_tsr_spctr_cst_off_k2");
LinModel<3> seq_tsr_spctr_off_k0(seq_tsr_spctr_off_k0_init,"seq_tsr_spctr_off_k0");
LinModel<3> seq_tsr_spctr_off_k1(seq_tsr_spctr_off_k1_init,"seq_tsr_spctr_off_k1");
LinModel<3> seq_tsr_spctr_off_k2(seq_tsr_spctr_off_k2_init,"seq_tsr_spctr_off_k2");
LinModel<3> seq_tsr_spctr_cst_k0(seq_tsr_spctr_cst_k0_init,"seq_tsr_spctr_cst_k0");
LinModel<3> seq_tsr_spctr_cst_k1(seq_tsr_spctr_cst_k1_init,"seq_tsr_spctr_cst_k1");
LinModel<3> seq_tsr_spctr_cst_k2(seq_tsr_spctr_cst_k2_init,"seq_tsr_spctr_cst_k2");
LinModel<3> seq_tsr_spctr_cst_k3(seq_tsr_spctr_cst_k3_init,"seq_tsr_spctr_cst_k3");
LinModel<3> seq_tsr_spctr_cst_k4(seq_tsr_spctr_cst_k4_init,"seq_tsr_spctr_cst_k4");
LinModel<3> seq_tsr_spctr_cst_k5(seq_tsr_spctr_cst_k5_init,"seq_tsr_spctr_cst_k5");
LinModel<3> seq_tsr_spctr_k0(seq_tsr_spctr_k0_init,"seq_tsr_spctr_k0");
LinModel<3> seq_tsr_spctr_k1(seq_tsr_spctr_k1_init,"seq_tsr_spctr_k1");
LinModel<3> seq_tsr_spctr_k2(seq_tsr_spctr_k2_init,"seq_tsr_spctr_k2");
LinModel<3> seq_tsr_spctr_k3(seq_tsr_spctr_k3_init,"seq_tsr_spctr_k3");
LinModel<3> seq_tsr_spctr_k4(seq_tsr_spctr_k4_init,"seq_tsr_spctr_k4");
LinModel<3> seq_tsr_spctr_k5(seq_tsr_spctr_k5_init,"seq_tsr_spctr_k5");
GlobalCostModel<3> seq_tsr_spctr_cst_off_k0(seq_tsr_spctr_cst_off_k0_init,"seq_tsr_spctr_cst_off_k0");
GlobalCostModel<3> seq_tsr_spctr_cst_off_k1(seq_tsr_spctr_cst_off_k1_init,"seq_tsr_spctr_cst_off_k1");
GlobalCostModel<3> seq_tsr_spctr_cst_off_k2(seq_tsr_spctr_cst_off_k2_init,"seq_tsr_spctr_cst_off_k2");
GlobalCostModel<3> seq_tsr_spctr_off_k0(seq_tsr_spctr_off_k0_init,"seq_tsr_spctr_off_k0");
GlobalCostModel<3> seq_tsr_spctr_off_k1(seq_tsr_spctr_off_k1_init,"seq_tsr_spctr_off_k1");
GlobalCostModel<3> seq_tsr_spctr_off_k2(seq_tsr_spctr_off_k2_init,"seq_tsr_spctr_off_k2");
GlobalCostModel<3> seq_tsr_spctr_cst_k0(seq_tsr_spctr_cst_k0_init,"seq_tsr_spctr_cst_k0");
GlobalCostModel<3> seq_tsr_spctr_cst_k1(seq_tsr_spctr_cst_k1_init,"seq_tsr_spctr_cst_k1");
GlobalCostModel<3> seq_tsr_spctr_cst_k2(seq_tsr_spctr_cst_k2_init,"seq_tsr_spctr_cst_k2");
GlobalCostModel<3> seq_tsr_spctr_cst_k3(seq_tsr_spctr_cst_k3_init,"seq_tsr_spctr_cst_k3");
GlobalCostModel<3> seq_tsr_spctr_cst_k4(seq_tsr_spctr_cst_k4_init,"seq_tsr_spctr_cst_k4");
GlobalCostModel<3> seq_tsr_spctr_cst_k5(seq_tsr_spctr_cst_k5_init,"seq_tsr_spctr_cst_k5");
GlobalCostModel<3> seq_tsr_spctr_k0(seq_tsr_spctr_k0_init,"seq_tsr_spctr_k0");
GlobalCostModel<3> seq_tsr_spctr_k1(seq_tsr_spctr_k1_init,"seq_tsr_spctr_k1");
GlobalCostModel<3> seq_tsr_spctr_k2(seq_tsr_spctr_k2_init,"seq_tsr_spctr_k2");
GlobalCostModel<3> seq_tsr_spctr_k3(seq_tsr_spctr_k3_init,"seq_tsr_spctr_k3");
GlobalCostModel<3> seq_tsr_spctr_k4(seq_tsr_spctr_k4_init,"seq_tsr_spctr_k4");
GlobalCostModel<3> seq_tsr_spctr_k5(seq_tsr_spctr_k5_init,"seq_tsr_spctr_k5");

double seq_tsr_spctr::est_time_fp(int nlyr, int nblk_A, int nblk_B, int nblk_C, double nnz_frac_A, double nnz_frac_B, double nnz_frac_C){
// return COST_MEMBW*(size_A+size_B+size_C)+COST_FLOP*flops;
Expand Down Expand Up @@ -995,7 +995,7 @@ namespace CTF_int {
}
}

LinModel<2> pin_keys_mdl(pin_keys_mdl_init,"pin_keys_mdl");
GlobalCostModel<2> pin_keys_mdl(pin_keys_mdl_init,"pin_keys_mdl");
double spctr_pin_keys::est_time_fp(int nlyr, int nblk_A, int nblk_B, int nblk_C, double nnz_frac_A, double nnz_frac_B, double nnz_frac_C) {
switch (AxBxC){
case 0:
Expand Down
14 changes: 7 additions & 7 deletions src/interface/common.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ namespace CTF_int {


//static double init_mdl[] = {COST_LATENCY, COST_LATENCY, COST_NETWBW};
LinModel<3> alltoall_mdl(alltoall_mdl_init,"alltoall_mdl");
LinModel<3> alltoallv_mdl(alltoallv_mdl_init,"alltoallv_mdl");
GlobalCostModel<3> alltoall_mdl(alltoall_mdl_init,"alltoall_mdl");
GlobalCostModel<3> alltoallv_mdl(alltoallv_mdl_init,"alltoallv_mdl");

#ifdef BGQ
//static double init_lg_mdl[] = {COST_LATENCY, COST_LATENCY, 0.0, COST_NETWBW + 2.0*COST_MEMBW};
#else
//static double init_lg_mdl[] = {COST_LATENCY, COST_LATENCY, COST_NETWBW + 2.0*COST_MEMBW, 0.0};
#endif
LinModel<3> red_mdl(red_mdl_init,"red_mdl");
LinModel<3> red_mdl_cst(red_mdl_cst_init,"red_mdl_cst");
LinModel<3> allred_mdl(allred_mdl_init,"allred_mdl");
LinModel<3> allred_mdl_cst(allred_mdl_cst_init,"allred_mdl_cst");
LinModel<3> bcast_mdl(bcast_mdl_init,"bcast_mdl");
GlobalCostModel<3> red_mdl(red_mdl_init,"red_mdl");
GlobalCostModel<3> red_mdl_cst(red_mdl_cst_init,"red_mdl_cst");
GlobalCostModel<3> allred_mdl(allred_mdl_init,"allred_mdl");
GlobalCostModel<3> allred_mdl_cst(allred_mdl_cst_init,"allred_mdl_cst");
GlobalCostModel<3> bcast_mdl(bcast_mdl_init,"bcast_mdl");


template <typename type>
Expand Down
2 changes: 1 addition & 1 deletion src/redistribution/dgtog_redist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "dgtog_bucket.h"
namespace CTF_int {
//static double init_mdl[] = {COST_LATENCY, COST_LATENCY, COST_NETWBW};
LinModel<3> dgtog_res_mdl(dgtog_res_mdl_init,"dgtog_res_mdl");
GlobalCostModel<3> dgtog_res_mdl(dgtog_res_mdl_init,"dgtog_res_mdl");

double dgtog_est_time(int64_t tot_sz, int np){
double ps[] = {1.0, (double)log2(np), (double)tot_sz*log2(np)};
Expand Down
6 changes: 3 additions & 3 deletions src/redistribution/nosym_transp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace CTF_int {

//static double init_ct_ps[] = {COST_LATENCY, 1.5*COST_MEMBW};
LinModel<2> long_contig_transp_mdl(long_contig_transp_mdl_init,"long_contig_transp_mdl");
LinModel<2> shrt_contig_transp_mdl(shrt_contig_transp_mdl_init,"shrt_contig_transp_mdl");
LinModel<2> non_contig_transp_mdl(non_contig_transp_mdl_init,"non_contig_transp_mdl");
GlobalCostModel<2> long_contig_transp_mdl(long_contig_transp_mdl_init,"long_contig_transp_mdl");
GlobalCostModel<2> shrt_contig_transp_mdl(shrt_contig_transp_mdl_init,"shrt_contig_transp_mdl");
GlobalCostModel<2> non_contig_transp_mdl(non_contig_transp_mdl_init,"non_contig_transp_mdl");


//#define OPT_NOSYM_TR
Expand Down
2 changes: 1 addition & 1 deletion src/redistribution/redist.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ namespace CTF_int {
}

//static double init_mdl[] = {COST_LATENCY, COST_LATENCY, COST_NETWBW};
LinModel<2> blres_mdl(blres_mdl_init,"blres_mdl");
GlobalCostModel<2> blres_mdl(blres_mdl_init,"blres_mdl");

double blres_est_time(int64_t tot_sz, int nv0, int nv1){
double ps[] = {(double)nv0+nv1, (double)tot_sz};
Expand Down
68 changes: 34 additions & 34 deletions src/shared/model.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace CTF_int {
#define REG_LAMBDA 1.E6

template <int nparam>
LinModel<nparam>::LinModel(double const * init_guess, char const * name_, int hist_size_){
GlobalCostModel<nparam>::GlobalCostModel(double const * init_guess, char const * name_, int hist_size_){
//initialize the model as active by default
is_active = true;
//copy initial static coefficients to initialzie model (defined in init_model.cxx)
Expand Down Expand Up @@ -146,15 +146,15 @@ namespace CTF_int {


template <int nparam>
LinModel<nparam>::LinModel(){
GlobalCostModel<nparam>::GlobalCostModel(){
//initialize the model as active by default
is_active = true;
name = NULL;
time_param_mat = NULL;
}

template <int nparam>
LinModel<nparam>::~LinModel(){
GlobalCostModel<nparam>::~GlobalCostModel(){
if (name != NULL) free(name);
#ifdef TUNE
if (time_param_mat != NULL) free(time_param_mat);
Expand All @@ -163,7 +163,7 @@ namespace CTF_int {


template <int nparam>
void LinModel<nparam>::observe(double const * tp){
void GlobalCostModel<nparam>::observe(double const * tp){
#ifdef TUNE
/*for (int i=0; i<nobs; i++){
bool is_same = true;
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace CTF_int {
}

template <int nparam>
bool LinModel<nparam>::should_observe(double const * tp){
bool GlobalCostModel<nparam>::should_observe(double const * tp){
#ifndef TUNE
ASSERT(0);
assert(0);
Expand All @@ -222,7 +222,7 @@ namespace CTF_int {


template <int nparam>
void LinModel<nparam>::update(MPI_Comm cm){
void GlobalCostModel<nparam>::update(MPI_Comm cm){
#ifdef TUNE
double S[nparam];
int lwork, liwork;
Expand Down Expand Up @@ -539,7 +539,7 @@ namespace CTF_int {
}

template <int nparam>
double LinModel<nparam>::est_time(double const * param){
double GlobalCostModel<nparam>::est_time(double const * param){
double d = 0.;
for (int i=0; i<nparam; i++){
d+=param[i]*coeff_guess[i];
Expand All @@ -548,7 +548,7 @@ namespace CTF_int {
}

template <int nparam>
void LinModel<nparam>::print(){
void GlobalCostModel<nparam>::print(){
assert(name!=NULL);
printf("double %s_init[] = {",name);
for (int i=0; i<nparam; i++){
Expand All @@ -559,20 +559,20 @@ namespace CTF_int {
}

template <int nparam>
void LinModel<nparam>::print_uo(){
void GlobalCostModel<nparam>::print_uo(){
if (nobs > 0){
printf("%s is_tuned = %d is_active = %d (%ld) avg_tot_time = %lf avg_over_time = %lf avg_under_time = %lf\n",name,(int)is_tuned,(int)is_active,nobs,avg_tot_time,avg_over_time,avg_under_time);
}
}


template <int nparam>
double* LinModel<nparam>::get_coeff(){
double* GlobalCostModel<nparam>::get_coeff(){
return coeff_guess;
}

template <int nparam>
void LinModel<nparam>::write_coeff(std::string file_name){
void GlobalCostModel<nparam>::write_coeff(std::string file_name){
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
// Only first process needs to dump the coefficient
Expand Down Expand Up @@ -633,7 +633,7 @@ namespace CTF_int {


template <int nparam>
void LinModel<nparam>::load_coeff(std::string file_name){
void GlobalCostModel<nparam>::load_coeff(std::string file_name){
// Generate the model name
std::string model_name = std::string(name);

Expand Down Expand Up @@ -697,7 +697,7 @@ namespace CTF_int {
}

template <int nparam>
void LinModel<nparam>::dump_data(std::string path){
void GlobalCostModel<nparam>::dump_data(std::string path){
int rank = 0;
int np, my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
Expand Down Expand Up @@ -734,11 +734,11 @@ namespace CTF_int {
}


template class LinModel<1>;
template class LinModel<2>;
template class LinModel<3>;
template class LinModel<4>;
template class LinModel<5>;
template class GlobalCostModel<1>;
template class GlobalCostModel<2>;
template class GlobalCostModel<3>;
template class GlobalCostModel<4>;
template class GlobalCostModel<5>;

/**
* Given params e.g. [x,y,z] outputs params [x,y,z,x*x,x*y,x*z,y*y,y*z,z*z,x*x*x,x*x*y,x*x*z,x*y*x, ....] etc
Expand Down Expand Up @@ -774,70 +774,70 @@ namespace CTF_int {


template <int nparam>
CubicModel<nparam>::CubicModel(double const * init_guess, char const * name, int hist_size)
GlobalPolyCostModel<nparam>::GlobalPolyCostModel(double const * init_guess, char const * name, int hist_size)
: lmdl(init_guess, name, hist_size)
{ }

template <int nparam>
CubicModel<nparam>::~CubicModel(){}
GlobalPolyCostModel<nparam>::~GlobalPolyCostModel(){}

template <int nparam>
void CubicModel<nparam>::update(MPI_Comm cm){
void GlobalPolyCostModel<nparam>::update(MPI_Comm cm){
lmdl.update(cm);
}

template <int nparam>
void CubicModel<nparam>::observe(double const * time_param){
void GlobalPolyCostModel<nparam>::observe(double const * time_param){
double ltime_param[nparam*(nparam+1)*(nparam+2)/6+nparam*(nparam+1)/2+nparam+1];
ltime_param[0] = time_param[0];
cube_params(time_param+1, ltime_param+1, nparam);
lmdl.observe(ltime_param);
}

template <int nparam>
bool CubicModel<nparam>::should_observe(double const * time_param){
bool GlobalPolyCostModel<nparam>::should_observe(double const * time_param){
return lmdl.should_observe(time_param);
}

template <int nparam>
double CubicModel<nparam>::est_time(double const * param){
double GlobalPolyCostModel<nparam>::est_time(double const * param){
double lparam[nparam*(nparam+1)*(nparam+2)/6+nparam*(nparam+1)/2+nparam];
cube_params(param, lparam, nparam);
return lmdl.est_time(lparam);
}

template <int nparam>
void CubicModel<nparam>::print(){
void GlobalPolyCostModel<nparam>::print(){
lmdl.print();
}

template <int nparam>
void CubicModel<nparam>::print_uo(){
void GlobalPolyCostModel<nparam>::print_uo(){
lmdl.print_uo();
}

template <int nparam>
double* CubicModel<nparam>::get_coeff(){
double* GlobalPolyCostModel<nparam>::get_coeff(){
return lmdl.get_coeff();
}

template <int nparam>
void CubicModel<nparam>::load_coeff(std::string file_name){
void GlobalPolyCostModel<nparam>::load_coeff(std::string file_name){
lmdl.load_coeff(file_name);
}

template <int nparam>
void CubicModel<nparam>::write_coeff(std::string file_name){
void GlobalPolyCostModel<nparam>::write_coeff(std::string file_name){
lmdl.write_coeff(file_name);
}

template <int nparam>
void CubicModel<nparam>::dump_data(std::string path){
void GlobalPolyCostModel<nparam>::dump_data(std::string path){
lmdl.dump_data(path);
}

template class CubicModel<1>;
template class CubicModel<2>;
template class CubicModel<3>;
template class CubicModel<4>;
template class GlobalPolyCostModel<1>;
template class GlobalPolyCostModel<2>;
template class GlobalPolyCostModel<3>;
template class GlobalPolyCostModel<4>;
}
16 changes: 8 additions & 8 deletions src/shared/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace CTF_int {
* \brief Linear performance models, which given measurements, provides new model guess
*/
template <int nparam>
class LinModel : Model {
class GlobalCostModel : Model {
private:
/** \brief number of performance observations made (calls to observe() */
int64_t nobs;
Expand Down Expand Up @@ -79,10 +79,10 @@ namespace CTF_int {
* \param[in] name identifier
* \param[in] hist_size number of times to keep in history
*/
LinModel(double const * init_guess, char const * name, int hist_size=32768);
GlobalCostModel(double const * init_guess, char const * name, int hist_size=32768);

LinModel();
~LinModel();
GlobalCostModel();
~GlobalCostModel();

/**
* \brief updates model based on observarions
Expand Down Expand Up @@ -146,9 +146,9 @@ namespace CTF_int {
* \brief Cubic performance models, which given measurements, provides new model guess
*/
template <int nparam>
class CubicModel : Model {
class GlobalPolyCostModel : Model {
private:
LinModel<nparam*(nparam+1)*(nparam+2)/6+nparam*(nparam+1)/2+nparam> lmdl;
GlobalCostModel<nparam*(nparam+1)*(nparam+2)/6+nparam*(nparam+1)/2+nparam> lmdl;

public:
/**
Expand All @@ -157,9 +157,9 @@ namespace CTF_int {
* \param[in] name identifier
* \param[in] hist_size number of times to keep in history
*/
CubicModel(double const * init_guess, char const * name, int hist_size=8192);
GlobalPolyCostModel(double const * init_guess, char const * name, int hist_size=8192);

~CubicModel();
~GlobalPolyCostModel();

/**
* \brief updates model based on observarions
Expand Down