1313#include " ReturnValues.h"
1414#include " ipm/hipo/auxiliary/Auxiliary.h"
1515#include " ipm/hipo/auxiliary/Log.h"
16+ #include " rcm/rcm.h"
1617
1718namespace hipo {
1819
@@ -21,8 +22,8 @@ const Int64 int64_limit = std::numeric_limits<int64_t>::max();
2122
2223Analyse::Analyse (const std::vector<Int>& rows, const std::vector<Int>& ptr,
2324 const std::vector<Int>& signs, Int nb, const Log* log,
24- DataCollector& data)
25- : log_{log}, data_{data} {
25+ DataCollector& data, const std::string& ordering )
26+ : log_{log}, data_{data}, ordering_{ordering} {
2627 // Input the symmetric matrix to be analysed in CSC format.
2728 // rows contains the row indices.
2829 // ptr contains the starting points of each column.
@@ -116,46 +117,74 @@ Int Analyse::getPermutation(bool metis_no2hop) {
116117 }
117118 }
118119
119- idx_t options[METIS_NOPTIONS];
120- METIS_SetDefaultOptions (options);
121- options[METIS_OPTION_SEED] = kMetisSeed ;
120+ if (ordering_ == " metis" ) {
121+ // ----------------------------
122+ // ----- METIS ----------------
123+ // ----------------------------
124+ idx_t options[METIS_NOPTIONS];
125+ METIS_SetDefaultOptions (options);
126+ options[METIS_OPTION_SEED] = kMetisSeed ;
122127
123- // set logging of Metis depending on debug level
124- options[METIS_OPTION_DBGLVL] = 0 ;
125- if (log_->debug (2 ))
126- options[METIS_OPTION_DBGLVL] = METIS_DBG_INFO | METIS_DBG_COARSEN;
128+ // set logging of Metis depending on debug level
129+ options[METIS_OPTION_DBGLVL] = 0 ;
130+ if (log_->debug (2 ))
131+ options[METIS_OPTION_DBGLVL] = METIS_DBG_INFO | METIS_DBG_COARSEN;
127132
128- // set no2hop=1 if the user requested it
129- if (metis_no2hop) options[METIS_OPTION_NO2HOP] = 1 ;
133+ // set no2hop=1 if the user requested it
134+ if (metis_no2hop) options[METIS_OPTION_NO2HOP] = 1 ;
130135
131- if (log_) log_->printDevInfo (" Running Metis\n " );
136+ if (log_) log_->printDevInfo (" Running Metis\n " );
132137
133- Int status = METIS_NodeND (&n_, temp_ptr.data (), temp_rows.data (), NULL ,
134- options, perm_.data (), iperm_.data ());
138+ Int status = METIS_NodeND (&n_, temp_ptr.data (), temp_rows.data (), NULL ,
139+ options, perm_.data (), iperm_.data ());
135140
136- if (log_) log_->printDevInfo (" Metis done\n " );
137- if (status != METIS_OK) {
138- if (log_) log_->printDevInfo (" Error with Metis\n " );
139- return kRetMetisError ;
141+ if (log_) log_->printDevInfo (" Metis done\n " );
142+ if (status != METIS_OK) {
143+ if (log_) log_->printDevInfo (" Error with Metis\n " );
144+ return kRetMetisError ;
145+ }
146+
147+ } else if (ordering_ == " amd" ) {
148+ // ----------------------------
149+ // ------ AMD -----------------
150+ // ----------------------------
151+ double control[AMD_CONTROL];
152+ amd_defaults (control);
153+ double info[AMD_INFO];
154+
155+ if (log_) log_->printDevInfo (" Running AMD\n " );
156+ Int status = amd_order (n_, temp_ptr.data (), temp_rows.data (), perm_.data (),
157+ control, info);
158+ if (log_) log_->printDevInfo (" AMD done\n " );
159+
160+ if (status != AMD_OK) {
161+ if (log_) log_->printDevInfo (" Error with AMD\n " );
162+ return kRetMetisError ;
163+ }
164+ inversePerm (perm_, iperm_);
140165 }
141166
142- /*
143- double control[AMD_CONTROL];
144- amd_defaults(control);
167+ else if (ordering_ == " rcm" ) {
168+ // ----------------------------
169+ // ------ RCM -----------------
170+ // ----------------------------
145171
146- double info[AMD_INFO];
172+ if (log_) log_->printDevInfo (" Running RCM\n " );
173+ Int status = genrcm (n_, temp_ptr.back (), temp_ptr.data (), temp_rows.data (),
174+ perm_.data ());
175+ if (log_) log_->printDevInfo (" RCM done\n " );
147176
148- Int status = amd_order(n_, temp_ptr.data(), temp_rows.data(), perm_.data(),
149- control, info);
177+ if (status != 0 ) {
178+ if (log_) log_->printDevInfo (" Error with RCM\n " );
179+ return kRetMetisError ;
180+ }
181+ inversePerm (perm_, iperm_);
150182
151- if (status != AMD_OK) {
152- if (log_) log_->printDevInfo("Error with AMD \n");
153- return kRetMetisError;
183+ } else {
184+ if (log_) log_->printe ( " Invalid reordering option \n " );
185+ return kRetMetisError ;
154186 }
155187
156- inversePerm(perm_, iperm_);
157- */
158-
159188 return kRetOk ;
160189}
161190
0 commit comments