Skip to content

Commit ccc9226

Browse files
authored
Merge pull request #26 from CODARcode/sm_release
Passing unit tests now and fixed detection loop for copod
2 parents 36cb99d + 011c5b2 commit ccc9226

5 files changed

Lines changed: 39 additions & 16 deletions

File tree

configure.ac

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[]],
4040
AC_ARG_ENABLE([mpi],
4141
AS_HELP_STRING([--disable-mpi], [Disable MPI. User will need to manually assign the rank index to the AD instances.]), [], [enable_mpi=yes])
4242

43-
AS_IF([test "x$enable_mpi" != "xno"], [
43+
AS_IF(
44+
[test "x$enable_mpi" != "xno"], [
4445
#Check we can compile with MPI
4546
AC_MSG_NOTICE([MPI use is enabled, checking compilation with MPI is possible])
4647
AC_CHECK_HEADER(mpi.h, [], [AC_MSG_FAILURE([["Cannot find MPI header"]])] )
4748
AC_DEFINE([USE_MPI],[1],[Use MPI])
48-
])
49+
LIBS+="-lpthread"
50+
],
51+
[test "x$enable_mpi" == "xno"], [
52+
AC_MSG_NOTICE([MPI use is disabled])
53+
LIBS+="-lpthread"
54+
]
55+
)
4956

5057

5158
#Check for curl config and library

spack/repo/chimbuko/packages/chimbuko-performance-analysis/package.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class ChimbukoPerformanceAnalysis(AutotoolsPackage):
1717
version('master', branch='master')
1818

1919
variant('perf-metric', default=True, description='Build with performance monitoring')
20-
21-
depends_on('mpi')
20+
variant('mpi', default=True, description='Enable building Chimbuko with MPI. If disabled the user must manually provide the rank index to the OAD.')
21+
22+
depends_on('mpi', when="+mpi")
2223
depends_on('cereal')
2324
depends_on('adios2')
2425
depends_on('googletest')
@@ -34,12 +35,15 @@ class ChimbukoPerformanceAnalysis(AutotoolsPackage):
3435

3536

3637
def setup_environment(self, spack_env, run_env):
37-
spack_env.set('CXX', self.spec['mpi'].mpicxx)
38+
if '+mpi' in self.spec:
39+
spack_env.set('CXX', self.spec['mpi'].mpicxx)
3840

3941
def configure_args(self):
4042
args = ["--with-network=ZMQ", "--with-adios2=%s" % self.spec['adios2'].prefix ]
4143

4244
if '+perf-metric' in self.spec:
4345
args.append('--with-perf-metric')
44-
46+
if '+mpi' not in self.spec:
47+
args.append('--disable-mpi')
48+
4549
return args

src/ad/ADNetClient.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,9 @@ void ADThreadNetClient::run(bool local){
428428
size_t nwork = getNwork();
429429
while(nwork > 0){
430430
ClientAction* work_item = getWorkItem();
431+
//Ask if shutdown is to be done *before* calling perform as blocking actions unlock the parent thread in perform which destroys the ClientAction object making the pointer invalid!
432+
shutdown = shutdown || work_item->shutdown_worker();
431433
work_item->perform(*client);
432-
shutdown = shutdown || work_item->shutdown_worker();
433434

434435
if(work_item->do_delete()) delete work_item;
435436
nwork = getNwork();

src/ad/ADOutlier.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,17 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
592592
std::vector<double> recon_p_runtimes = std::vector<double>(tot_runtimes, 0.0);
593593
std::vector<double> recon_n_runtimes = std::vector<double>(tot_runtimes, 0.0);
594594
int recon_idx = 0;
595+
//verboseStream << "Unwrapping Merged Histogram. Size: " << param[func_id].counts().size() << std::endl;
595596
for(int i=0; i < param[func_id].counts().size(); i++){
596597
int count = param[func_id].counts().at(i);
598+
//verboseStream << "Count: " << count << ", Value: " << param[func_id].bin_edges().at(i) << std::endl;
597599
for(int j=0; j<count; j++){
598-
recon_p_runtimes.at(recon_idx++) = param[func_id].bin_edges().at(i);
599-
recon_n_runtimes.at(recon_idx++) = -1 * param[func_id].bin_edges().at(i);
600+
601+
recon_p_runtimes.at(recon_idx) = param[func_id].bin_edges().at(i);
602+
recon_n_runtimes.at(recon_idx) = -1 * param[func_id].bin_edges().at(i);
603+
//verboseStream << "recon_p_runtimes.at(recon_idx): " << recon_p_runtimes.at(recon_idx) << ", recon_n_runtimes.at(recon_idx): " << recon_n_runtimes.at(recon_idx) << std::endl;
604+
//verboseStream << "recon_idx: " << recon_idx << std::endl;
605+
recon_idx++;
600606
}
601607
}
602608

@@ -664,8 +670,9 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
664670

665671
const double runtime_i = this->getStatisticValue(*itt); //runtimes.push_back(this->getStatisticValue(*itt));
666672
double ad_score;
667-
668-
if (mean_pn_ecdf.at(running_idx++) > 0)
673+
674+
//verboseStream << "mean_pn_ecdf.at(running_idx++): " << mean_pn_ecdf.at(running_idx) << std::endl;
675+
if (mean_pn_ecdf.at(running_idx++) < 0.99)
669676
ad_score = l_threshold + 1;
670677
else
671678
ad_score = l_threshold - 1;
@@ -686,8 +693,8 @@ unsigned long ADOutlierCOPOD::compute_outliers(Anomalies &outliers,
686693
//Capture maximum of one normal execution per io step
687694
itt->set_label(1);
688695
if(outliers.nFuncEvents(func_id, Anomalies::EventType::Normal) == 0) {
689-
verboseStream << "Detected normal event on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
690-
outliers.insert(itt, Anomalies::EventType::Normal);
696+
verboseStream << "Detected normal event on func id " << func_id << " (" << itt->get_funcname() << ") on thread " << itt->get_tid() << " runtime " << runtime_i << std::endl;
697+
outliers.insert(itt, Anomalies::EventType::Normal);
691698
}
692699

693700
}
@@ -720,9 +727,9 @@ int ADOutlierCOPOD::np_digitize_get_bin_inds(const double& X, const std::vector<
720727
}
721728

722729
std::vector<double> ADOutlierCOPOD::empiricalCDF(const std::vector<double>& runtimes, const bool sorted) {
723-
724-
std::vector<double> tmp_runtimes = runtimes;
725-
auto ecdf = boost::math::empirical_cumulative_distribution_function(std::move(tmp_runtimes));
730+
731+
std::vector<double> tmp_runtimes = runtimes;
732+
auto ecdf = boost::math::empirical_cumulative_distribution_function(std::move(tmp_runtimes));
726733
std::vector<double> result_ecdf = std::vector<double>(runtimes.size(), 0.0);
727734
for(int i=0; i < runtimes.size(); i++) {
728735
result_ecdf.at(i) = ecdf(runtimes.at(i));

src/param.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "chimbuko/param.hpp"
22
#include "chimbuko/param/sstd_param.hpp"
33
#include "chimbuko/param/hbos_param.hpp"
4+
#include "chimbuko/param/copod_param.hpp"
45
#include <chrono>
56

67
using namespace chimbuko;
@@ -17,6 +18,9 @@ ParamInterface *ParamInterface::set_AdParam(const std::string & ad_algorithm) {
1718
else if (ad_algorithm == "sstd" || ad_algorithm == "SSTD") {
1819
return new SstdParam();
1920
}
21+
else if (ad_algorithm == "copod" || ad_algorithm == "COPOD") {
22+
return new CopodParam();
23+
}
2024
else {
2125
return nullptr;
2226
}

0 commit comments

Comments
 (0)