id
int64 0
877k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
66
| repo_stars
int64 94
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 11
values | repo_extraction_date
stringclasses 197
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,541,222
|
KeysConvertor.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/convertors/KeysConvertor.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/utils/convertors/KeysConvertor.hpp>
using namespace bs::io::utils::convertors;
using namespace bs::io::dataunits;
using namespace bs::base::exceptions;
TraceHeaderKey
KeysConvertor::ToTraceHeaderKey(std::string &aKey) {
char key_char[aKey.length()];
strcpy(key_char, aKey.c_str());
for (int i = 0; i < aKey.length(); ++i) {
key_char[i] = toupper(key_char[i]);
}
auto val = KeysConvertor::mTraceKeyMap.find(key_char);
if (val == KeysConvertor::mTraceKeyMap.end()) {
throw NO_KEY_FOUND_EXCEPTION();
}
return {val->second};
}
const std::unordered_map<std::string, TraceHeaderKey::Key> KeysConvertor::mTraceKeyMap = {
{"TRACL", TraceHeaderKey::TRACL},
{"TRACR", TraceHeaderKey::TRACR},
{"FLDR", TraceHeaderKey::FLDR},
{"TRACF", TraceHeaderKey::TRACF},
{"EP", TraceHeaderKey::EP},
{"CDP", TraceHeaderKey::CDP},
{"CDPT", TraceHeaderKey::CDPT},
{"TRID", TraceHeaderKey::TRID},
{"NVS", TraceHeaderKey::NVS},
{"NHS", TraceHeaderKey::NHS},
{"DUSE", TraceHeaderKey::DUSE},
{"OFFSET", TraceHeaderKey::OFFSET},
{"GELEV", TraceHeaderKey::GELEV},
{"SELEV", TraceHeaderKey::SELEV},
{"SDEPTH", TraceHeaderKey::SDEPTH},
{"GDEL", TraceHeaderKey::GDEL},
{"SDEL", TraceHeaderKey::SDEL},
{"SWDEP", TraceHeaderKey::SWDEP},
{"DWDEP", TraceHeaderKey::GWDEP},
{"SCALEL", TraceHeaderKey::SCALEL},
{"SCALCO", TraceHeaderKey::SCALCO},
{"SX", TraceHeaderKey::SX},
{"SY", TraceHeaderKey::SY},
{"GX", TraceHeaderKey::GX},
{"GY", TraceHeaderKey::GY},
{"COINTIT", TraceHeaderKey::COINTIT},
{"WEVEL", TraceHeaderKey::WEVEL},
{"SWEVEL", TraceHeaderKey::SWEVEL},
{"SUT", TraceHeaderKey::SUT},
{"GUT", TraceHeaderKey::GUT},
{"SSTAT", TraceHeaderKey::SSTAT},
{"GSTAT", TraceHeaderKey::GSTAT},
{"TSTAT", TraceHeaderKey::TSTAT},
{"LAGA", TraceHeaderKey::LAGA},
{"LAGB", TraceHeaderKey::LAGB},
{"DELRT", TraceHeaderKey::DELRT},
{"MUTS", TraceHeaderKey::MUTS},
{"MUTE", TraceHeaderKey::MUTE},
{"DT", TraceHeaderKey::DT},
{"GAIN", TraceHeaderKey::GAIN},
{"IGC", TraceHeaderKey::IGC},
{"IGI", TraceHeaderKey::IGI},
{"CORR", TraceHeaderKey::CORR},
{"SFS", TraceHeaderKey::SFS},
{"SFE", TraceHeaderKey::SFE},
{"SLEN", TraceHeaderKey::SLEN},
{"STYP", TraceHeaderKey::STYP},
{"STAS", TraceHeaderKey::STAS},
{"STAE", TraceHeaderKey::STAE},
{"TATYP", TraceHeaderKey::TATYP},
{"AFILF", TraceHeaderKey::AFILF},
{"AFILS", TraceHeaderKey::AFILS},
{"NOFILF", TraceHeaderKey::NOFILF},
{"NOFILS", TraceHeaderKey::NOFILS},
{"LCF", TraceHeaderKey::LCF},
{"HCF", TraceHeaderKey::HCF},
{"LCS", TraceHeaderKey::LCS},
{"HCS", TraceHeaderKey::HCS},
{"YEAR", TraceHeaderKey::YEAR},
{"DAY", TraceHeaderKey::DAY},
{"HOUR", TraceHeaderKey::HOUR},
{"MINUTE", TraceHeaderKey::MINUTE},
{"SEC", TraceHeaderKey::SEC},
{"TIMBAS", TraceHeaderKey::TIMBAS},
{"TRWF", TraceHeaderKey::TRWF},
{"GRNORS", TraceHeaderKey::GRNORS},
{"GRNOFR", TraceHeaderKey::GRNOFR},
{"GRNLOF", TraceHeaderKey::GRNLOF},
{"GAPS", TraceHeaderKey::GAPS},
{"OTRAV", TraceHeaderKey::OTRAV},
{"D1", TraceHeaderKey::D1},
{"F1", TraceHeaderKey::F1},
{"D2", TraceHeaderKey::D2},
{"F2", TraceHeaderKey::F2},
{"UNGPOW", TraceHeaderKey::UNGPOW},
{"UNSCALE", TraceHeaderKey::UNSCALE},
{"NTR", TraceHeaderKey::NTR},
{"MARK", TraceHeaderKey::MARK},
{"SHORTPAD", TraceHeaderKey::SHORTPAD},
{"NS", TraceHeaderKey::NS},
{"DATA_BYTE_OFFSET", TraceHeaderKey::DATA_BYTE_OFFSET}
};
| 5,724
|
C++
|
.cpp
| 120
| 40.7
| 90
| 0.513668
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,223
|
FloatingPointFormatter.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/convertors/FloatingPointFormatter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/utils/convertors/FloatingPointFormatter.hpp>
#include <bs/io/utils/checkers/Checker.hpp>
using namespace bs::base::exceptions;
using namespace bs::io::utils::convertors;
using namespace bs::io::utils::checkers;
int
FloatingPointFormatter::GetFloatArrayRealSize(unsigned short aSamplesNumber, unsigned short aFormatCode) {
int size;
if (aFormatCode == 1 || aFormatCode == 2 || aFormatCode == 4 || aFormatCode == 5) {
size = 4 * aSamplesNumber;
} else if (aFormatCode == 3) {
size = 2 * aSamplesNumber;
} else if (aFormatCode == 8) {
size = aSamplesNumber;
} else {
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
return size;
}
int
FloatingPointFormatter::Format(const char *apSrc, char *apDest,
size_t aSrcSize, size_t aSamplesNumber,
short aFormat, bool aFromFormat) {
int rc;
if (aFromFormat) {
switch (aFormat) {
case 1:
/// Convert IBM float to native floats.
rc = FloatingPointFormatter::FromIBM(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
case 2:
/// Convert 4 byte two's complement integer to native floats.
rc = FloatingPointFormatter::FromLong(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
case 3:
/// Convert 2 byte two's complement integer to native floats.
rc = FloatingPointFormatter::FromShort(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
case 5:
/// Convert IEEE float to native floats.
rc = FloatingPointFormatter::FromIEEE(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
case 8:
/// Convert 1 byte two's complement integer to native floats.
rc = FloatingPointFormatter::FromChar(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
default:
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
} else {
switch (aFormat) {
case 1:
/// Convert IBM float to native floats.
rc = FloatingPointFormatter::ToIBM(apSrc, apDest, aSrcSize, aSamplesNumber);
break;
default:
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
}
return rc;
}
int
FloatingPointFormatter::FromIBM(const char *apSrc, char *apDest,
size_t aSrcSize, size_t aSamplesNumber) {
bool is_little_endian = Checker::IsLittleEndianMachine();
size_t size_entry = sizeof(float);
size_t size = aSrcSize / size_entry;
unsigned int fconv, fmant, t;
unsigned int offset = 0;
for (int i = 0; i < size; ++i) {
offset = i * size_entry;
memcpy(&fconv, apSrc + offset, sizeof(unsigned int));
if (is_little_endian) {
fconv = (fconv << 24) | ((fconv >> 24) & 0xff) | ((fconv & 0xff00) << 8) |
((fconv & 0xff0000) >> 8);
}
if (fconv) {
fmant = 0x00ffffff & fconv;
t = (int) ((0x7f000000 & fconv) >> 22) - 130;
while (!(fmant & 0x00800000)) {
--t;
fmant <<= 1;
}
if (t > 254) {
fconv = (0x80000000 & fconv) | 0x7f7fffff;
} else if (t <= 0) {
fconv = 0;
} else {
fconv = (0x80000000 & fconv) | (t << 23) | (0x007fffff & fmant);
}
}
memcpy(apDest + offset, &fconv, sizeof(float));
}
return 1;
}
int
FloatingPointFormatter::ToIBM(const char *apSrc, char *apDest,
size_t aSrcSize, size_t aSamplesNumber) {
bool is_little_endian = Checker::IsLittleEndianMachine();
size_t size_entry = sizeof(float);
size_t size = aSrcSize / size_entry;
unsigned int fconv, fmant, t;
unsigned int offset = 0;
unsigned fr; /* fraction */
int exp; /* exponent */
int sgn; /* sign */
for (int i = 0; i < size; ++i) {
offset = i * size_entry;
memcpy(&fconv, apSrc + offset, sizeof(unsigned int));
if (fconv) {
fr = fconv; /* pick up value */
sgn = fr >> 31; /* save sign */
fr <<= 1; /* shift sign out */
exp = fr >> 24; /* save exponent */
fr <<= 8; /* shift exponent out */
if (exp == 255) { /* infinity (or NAN) - map to largest */
fr = 0xffffff00;
exp = 0x7f;
goto done;
} else if (exp > 0) /* add assumed digit */
fr = (fr >> 1) | 0x80000000;
else if (fr == 0) /* short-circuit for zero */
goto done;
/* adjust exponent from base 2 offset 127 radix point after first digit
to base 16 offset 64 radix point before first digit */
exp += 130;
fr >>= -exp & 3;
exp = (exp + 3) >> 2;
/* (re)normalize */
while (fr < 0x10000000) { /* never executed for normalized input */
--exp;
fr <<= 4;
}
done:
/* put the pieces back together and return it */
fr = (fr >> 8) | (exp << 24) | (sgn << 31);
fconv = fr;
}
// Swap endian after transformation.
if (is_little_endian) {
fconv = (fconv << 24) | ((fconv >> 24) & 0xff) | ((fconv & 0xff00) << 8) |
((fconv & 0xff0000) >> 8);
}
memcpy(apDest + offset, &fconv, sizeof(float));
}
return 1;
}
int
FloatingPointFormatter::FromLong(const char *apSrc, char *apDest,
size_t aSize, size_t aSamplesNumber) {
/// @todo To be removed
/// {
throw NOT_IMPLEMENTED_EXCEPTION();
/// }
return 1;
}
int
FloatingPointFormatter::FromShort(const char *apSrc, char *apDest,
size_t aSize, size_t aSamplesNumber) {
/// @todo To be removed
/// {
throw NOT_IMPLEMENTED_EXCEPTION();
/// }
return 1;
}
int
FloatingPointFormatter::FromIEEE(const char *apSrc, char *apDest,
size_t aSize, size_t aSamplesNumber) {
/// @todo To be removed
/// {
throw NOT_IMPLEMENTED_EXCEPTION();
/// }
return 1;
}
int
FloatingPointFormatter::FromChar(const char *apSrc, char *apDest,
size_t aSize, size_t aSamplesNumber) {
/// @todo To be removed
/// {
throw NOT_IMPLEMENTED_EXCEPTION();
/// }
return 1;
}
| 7,607
|
C++
|
.cpp
| 202
| 28.311881
| 106
| 0.551089
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,224
|
Checker.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/checkers/Checker.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include <bs/io/utils/checkers/Checker.hpp>
using namespace bs::io::utils::checkers;
bool
Checker::IsLittleEndianMachine() {
volatile uint32_t i = 0x01234567;
return (*((uint8_t *) (&i))) == 0x67;
}
| 965
|
C++
|
.cpp
| 26
| 34.961538
| 73
| 0.737687
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,225
|
PlaneReflectorGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/synthetic-generators/concrete/PlaneReflectorGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/io/utils/synthetic-generators/concrete/PlaneReflectorGenerator.hpp>
using namespace bs::io::generators;
PlaneReflectorGenerator::PlaneReflectorGenerator()
: mValueBefore(0),
mValueAfter(0),
mOriginX(0),
mOriginY(0),
mOriginZ(0),
mXSlopeAngle(0),
mYSlopeAngle(0) {}
PlaneReflectorGenerator::~PlaneReflectorGenerator() = default;
void
PlaneReflectorGenerator::ParseValues(nlohmann::json &aJsonNode) {
this->mValueBefore = aJsonNode["value"]["before"];
this->mValueAfter = aJsonNode["value"]["after"];
this->mOriginX = aJsonNode["origin"]["x-index"];
this->mOriginY = aJsonNode["origin"]["y-index"];
this->mOriginZ = aJsonNode["origin"]["z-index"];
this->mXSlopeAngle = aJsonNode["slope"]["x-angle"];
this->mYSlopeAngle = aJsonNode["slope"]["y-angle"];
}
float
PlaneReflectorGenerator::GetReflectorDepth(float x, float y) {
return tanf(this->mXSlopeAngle * M_PI / 180) * (x - this->mOriginX)
+ tanf(this->mYSlopeAngle * M_PI / 180) * (y - this->mOriginY)
+ this->mOriginZ;
}
float
PlaneReflectorGenerator::GetAfterValue() {
return this->mValueAfter;
}
float PlaneReflectorGenerator::GetBeforeValue() {
return this->mValueBefore;
}
| 2,014
|
C++
|
.cpp
| 52
| 34.730769
| 80
| 0.710701
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,226
|
ShotsMetaDataGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/synthetic-generators/concrete/ShotsMetaDataGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/utils/synthetic-generators/concrete/ShotsMetaDataGenerator.hpp>
#define IO_SPACE_SCALE_FACTOR 1e3
#define IO_TIME_SCALE_FACTOR 1e6f
using namespace std;
using namespace bs::io::generators;
using namespace bs::io::dataunits;
ShotsMetaDataGenerator::~ShotsMetaDataGenerator() = default;
ShotsMetaDataGenerator::ShotsMetaDataGenerator(nlohmann::json aJsonNode)
: mGatherKey(TraceHeaderKey::NS) {
/// @todo: add better error handling-parsing.
this->mSamplingX = aJsonNode[IO_K_SYN_CELL_SAMP][IO_K_SYN_CELL_SAMP_X];
this->mSamplingY = aJsonNode[IO_K_SYN_CELL_SAMP][IO_K_SYN_CELL_SAMP_Y];
this->mTimeSampling = aJsonNode[IO_K_SYN_DT];
this->mSampleNumber = aJsonNode[IO_K_SYN_NS];
this->mSourceStart.x = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_START]
[IO_K_SYN_X_INDEX];
this->mSourceStart.y = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_START]
[IO_K_SYN_Y_INDEX];
this->mSourceStart.z = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_START]
[IO_K_SYN_Z_INDEX];
this->mSourceEnd.x = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_END]
[IO_K_SYN_X_INDEX];
this->mSourceEnd.y = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_END]
[IO_K_SYN_Y_INDEX];
this->mSourceEnd.z = aJsonNode[IO_K_SYN_SOURCE][IO_K_SYN_END]
[IO_K_SYN_Z_INDEX];
this->mSourceIncrement.x = aJsonNode[IO_K_SYN_SOURCE]
[IO_K_SYN_INCREMENT][IO_K_SYN_X_INDEX];
this->mSourceIncrement.y = aJsonNode[IO_K_SYN_SOURCE]
[IO_K_SYN_INCREMENT][IO_K_SYN_Y_INDEX];
this->mSourceIncrement.z = aJsonNode[IO_K_SYN_SOURCE]
[IO_K_SYN_INCREMENT][IO_K_SYN_Z_INDEX];
this->mReceiverRelStart.x = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_START][IO_K_SYN_X_OFFSET];
this->mReceiverRelStart.y = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_START][IO_K_SYN_Y_OFFSET];
this->mReceiverRelStart.z = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_START][IO_K_SYN_Z_OFFSET];
this->mReceiverNumber.x = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_NUMBER][IO_K_SYN_X];
this->mReceiverNumber.y = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_NUMBER][IO_K_SYN_Y];
this->mReceiverNumber.z = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_NUMBER][IO_K_SYN_Z];
this->mReceiverIncrement.x = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_INCREMENT][IO_K_SYN_X_INDEX];
this->mReceiverIncrement.y = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_INCREMENT][IO_K_SYN_Y_INDEX];
this->mReceiverIncrement.z = aJsonNode[IO_K_SYN_REC_REL]
[IO_K_SYN_INCREMENT][IO_K_SYN_Z_INDEX];
this->mOriginX = aJsonNode[IO_K_SYN_ORIGIN][IO_K_SYN_X];
this->mOriginY = aJsonNode[IO_K_SYN_ORIGIN][IO_K_SYN_Y];
this->mReceiverNumber.x = this->mReceiverNumber.x == 0 ? 1 : this->mReceiverNumber.x;
this->mReceiverNumber.y = this->mReceiverNumber.y == 0 ? 1 : this->mReceiverNumber.y;
this->mReceiverNumber.z = this->mReceiverNumber.z == 0 ? 1 : this->mReceiverNumber.z;
this->mSourceIncrement.x = this->mSourceIncrement.x == 0 ? 1 : this->mSourceIncrement.x;
this->mSourceIncrement.y = this->mSourceIncrement.y == 0 ? 1 : this->mSourceIncrement.y;
this->mSourceIncrement.z = this->mSourceIncrement.z == 0 ? 1 : this->mSourceIncrement.z;
}
void
ShotsMetaDataGenerator::SetGenerationKey(vector<TraceHeaderKey> &aHeaderKeys) {
if (aHeaderKeys.size() != 1) {
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
this->mGatherKey = aHeaderKeys[0];
if (this->mGatherKey != TraceHeaderKey::FLDR) {
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
}
vector<Gather *>
ShotsMetaDataGenerator::GetAllTraces() {
std::vector<io::dataunits::Gather *> results;
int inc_x = this->mSourceIncrement.x;
int inc_y = this->mSourceIncrement.y;
int shot_id = 1;
for (int sy = this->mSourceStart.y; sy <= this->mSourceEnd.y; sy += inc_y) {
for (int sx = this->mSourceStart.x; sx <= this->mSourceEnd.x; sx += inc_x) {
auto gather = new Gather();
for (int ry = 0; ry < this->mReceiverNumber.y; ry++) {
for (int rx = 0; rx < this->mReceiverNumber.x; rx++) {
auto trace = new Trace(this->mSampleNumber);
int16_t factor = -IO_SPACE_SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SCALCO, factor);
float src_x = this->mOriginX + sx * this->mSamplingX;
float src_y = this->mOriginY + sy * this->mSamplingY;
float rec_x = this->mOriginX
+ (sx + this->mReceiverRelStart.x
+ rx * this->mReceiverIncrement.x) *
this->mSamplingX;
float rec_y = this->mOriginY
+ (sy + this->mReceiverRelStart.y
+ ry * this->mReceiverIncrement.y) *
this->mSamplingY;
trace->SetScaledCoordinateHeader(TraceHeaderKey::SX, src_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::SY, src_y);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GX, rec_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GY, rec_y);
uint16_t sampling = this->mTimeSampling * IO_TIME_SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::DT, sampling);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_X_IND, sx);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_Y_IND, sy);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::FLDR, shot_id);
trace->SetTraceData(new float[this->mSampleNumber]);
memset(trace->GetTraceData(), 0, this->mSampleNumber * sizeof(float));
gather->AddTrace(trace);
}
}
gather->SetSamplingRate(this->mTimeSampling * IO_TIME_SCALE_FACTOR);
std::string shot_id_string = std::to_string(shot_id);
gather->SetUniqueKeyValue(this->mGatherKey,
shot_id_string);
shot_id++;
results.push_back(gather);
}
}
return results;
}
vector<Gather *>
ShotsMetaDataGenerator::GetTraces(vector<vector<string>> aHeaderValues) {
std::vector<io::dataunits::Gather *> results;
int number_of_source_x = abs(this->mSourceEnd.x - this->mSourceStart.x) + abs(this->mSourceIncrement.x);
number_of_source_x = number_of_source_x / abs(this->mSourceIncrement.x);
for (auto const &header_value : aHeaderValues) {
int shot_number = stoi(header_value[0]);
int shot_number_mod = shot_number - 1;
int x_iter = shot_number_mod % number_of_source_x;
int y_iter = shot_number_mod / number_of_source_x;
int sx = this->mSourceStart.x + x_iter * this->mSourceIncrement.x;
int sy = this->mSourceStart.y + y_iter * this->mSourceIncrement.y;
auto gather = new Gather();
for (int ry = 0; ry < this->mReceiverNumber.y; ry++) {
for (int rx = 0; rx < this->mReceiverNumber.x; rx++) {
auto trace = new Trace(this->mSampleNumber);
int16_t factor = -IO_SPACE_SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SCALCO, factor);
float src_x = this->mOriginX + sx * this->mSamplingX;
float src_y = this->mOriginY + sy * this->mSamplingY;
float rec_x = this->mOriginX
+ (sx + this->mReceiverRelStart.x
+ rx * this->mReceiverIncrement.x) *
this->mSamplingX;
float rec_y = this->mOriginY
+ (sy + this->mReceiverRelStart.y
+ ry * this->mReceiverIncrement.y) *
this->mSamplingY;
trace->SetScaledCoordinateHeader(TraceHeaderKey::SX, src_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::SY, src_y);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GX, rec_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GY, rec_y);
uint16_t sampling = this->mTimeSampling * IO_TIME_SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::DT, sampling);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_X_IND, sx);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_Y_IND, sy);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::FLDR, shot_number);
trace->SetTraceData(new float[this->mSampleNumber]);
memset(trace->GetTraceData(), 0, this->mSampleNumber * sizeof(float));
gather->AddTrace(trace);
}
}
gather->SetSamplingRate(this->mTimeSampling * IO_TIME_SCALE_FACTOR);
std::string shot_number_mod_string = std::to_string(shot_number_mod + 1);
gather->SetUniqueKeyValue(this->mGatherKey,
shot_number_mod_string);
results.push_back(gather);
}
return results;
}
vector<std::vector<std::string>>
ShotsMetaDataGenerator::GetGatherUniqueValues() {
uint source_number = GetSourceNumber();
std::vector<std::vector<std::string>> results;
results.reserve(source_number);
for (uint i = 0; i < source_number; i++) {
results.push_back(vector<string>{to_string(i + 1)});
}
return results;
}
uint
ShotsMetaDataGenerator::GetGatherNumber() {
return GetSourceNumber() * GetReceiverNumber();
}
uint
ShotsMetaDataGenerator::GetSourceNumber() const {
uint number_of_source_x = abs(this->mSourceEnd.x - this->mSourceStart.x) + abs(this->mSourceIncrement.x);
number_of_source_x = number_of_source_x / abs(this->mSourceIncrement.x);
uint number_of_source_y = abs(this->mSourceEnd.y - this->mSourceStart.y) + abs(this->mSourceIncrement.y);
number_of_source_y = number_of_source_y / abs(this->mSourceIncrement.y);
uint number_of_source_z = abs(this->mSourceEnd.z - this->mSourceStart.z) + abs(this->mSourceIncrement.z);
number_of_source_z = number_of_source_z / abs(this->mSourceIncrement.z);
uint number_of_sources = number_of_source_x * number_of_source_y * number_of_source_z;
return number_of_sources;
}
uint
ShotsMetaDataGenerator::GetReceiverNumber() const {
uint number_receiver_per_shot = 1;
number_receiver_per_shot *= this->mReceiverNumber.x;
number_receiver_per_shot *= this->mReceiverNumber.y;
number_receiver_per_shot *= this->mReceiverNumber.z;
return number_receiver_per_shot;
}
| 11,508
|
C++
|
.cpp
| 219
| 43.13242
| 109
| 0.636364
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,227
|
ParameterMetaDataGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/utils/synthetic-generators/concrete/ParameterMetaDataGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/utils/synthetic-generators/concrete/ParameterMetaDataGenerator.hpp>
#define SCALE_FACTOR 1e3
using namespace std;
using namespace bs::io::generators;
using namespace bs::io::dataunits;
ParameterMetaDataGenerator::ParameterMetaDataGenerator(nlohmann::json aJsonNode)
: mGatherKey(TraceHeaderKey::NS) {
//TODO add better error handling-parsing.
this->mSamplingX = aJsonNode[IO_K_SYN_CELL_SAMP][IO_K_SYN_CELL_SAMP_X];
this->mSamplingY = aJsonNode[IO_K_SYN_CELL_SAMP][IO_K_SYN_CELL_SAMP_Y];
this->mSamplingZ = aJsonNode[IO_K_SYN_CELL_SAMP][IO_K_SYN_CELL_SAMP_Z];
this->mOriginX = aJsonNode[IO_K_SYN_ORIGIN][IO_K_SYN_X];
this->mOriginY = aJsonNode[IO_K_SYN_ORIGIN][IO_K_SYN_Y];
this->mPointsX = aJsonNode[IO_K_SYN_GRIZ_SIZE][IO_K_SYN_NX];
this->mPointsY = aJsonNode[IO_K_SYN_GRIZ_SIZE][IO_K_SYN_NY];
this->mPointsZ = aJsonNode[IO_K_SYN_GRIZ_SIZE][IO_K_SYN_NZ];
}
void
ParameterMetaDataGenerator::SetGenerationKey(vector<TraceHeaderKey> &aHeaderKeys) {
if (aHeaderKeys.size() > 1) {
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
if (aHeaderKeys.size() == 1) {
this->mGatherKey = aHeaderKeys[0];
} else {
this->mGatherKey = TraceHeaderKey::FLDR;
}
if (this->mGatherKey != TraceHeaderKey::FLDR) {
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
}
vector<Gather *>
ParameterMetaDataGenerator::GetAllTraces() {
std::vector<io::dataunits::Gather *> results;
auto gather = new Gather();
for (int y = 0; y < this->mPointsY; y++) {
for (int x = 0; x < this->mPointsX; x++) {
auto trace = new Trace(this->mPointsZ);
int16_t factor = -SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SCALCO, factor);
float loc_x = this->mOriginX + x * this->mSamplingX;
float loc_y = this->mOriginY + y * this->mSamplingY;
trace->SetScaledCoordinateHeader(TraceHeaderKey::SX, loc_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::SY, loc_y);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GX, loc_x);
trace->SetScaledCoordinateHeader(TraceHeaderKey::GY, loc_y);
uint16_t sampling = this->mSamplingZ * SCALE_FACTOR;
trace->SetTraceHeaderKeyValue(TraceHeaderKey::DT, sampling);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_X_IND, x);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::SYN_Y_IND, y);
trace->SetTraceHeaderKeyValue(TraceHeaderKey::FLDR, 1);
trace->SetTraceData(new float[this->mPointsZ]);
memset(trace->GetTraceData(), 0, this->mPointsZ * sizeof(float));
gather->AddTrace(trace);
}
}
gather->SetSamplingRate(this->mSamplingZ * SCALE_FACTOR);
std::string value = std::to_string(1);
gather->SetUniqueKeyValue(this->mGatherKey, value);
results.push_back(gather);
return results;
}
vector<Gather *>
ParameterMetaDataGenerator::GetTraces(vector<vector<string>> aHeaderValues) {
std::vector<io::dataunits::Gather *> results;
if (aHeaderValues[0][0] == "1") {
results = this->GetAllTraces();
}
return results;
}
vector<std::vector<std::string>>
ParameterMetaDataGenerator::GetGatherUniqueValues() {
std::vector<std::vector<std::string>> results = {{"1"}};
return results;
}
uint
ParameterMetaDataGenerator::GetGatherNumber() {
return 1;
}
| 4,265
|
C++
|
.cpp
| 98
| 38.204082
| 83
| 0.693288
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,228
|
IndexMap.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/indexers/IndexMap.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/common/ExitCodes.hpp>
#include <bs/io/indexers/IndexMap.hpp>
using namespace bs::io::indexers;
using namespace bs::io::dataunits;
IndexMap::IndexMap() = default;
IndexMap::~IndexMap() = default;
int
IndexMap::Reset() {
this->mIndexMap.clear();
return BS_BASE_RC_SUCCESS;
}
std::map<std::string, std::vector<size_t>>
IndexMap::Get(const std::string &aTraceHeaderKey, std::vector<std::string> &aTraceHeaderValues) {
std::map<std::string, std::vector<size_t>> bytes;
for (auto &it : aTraceHeaderValues) {
bytes[it] = this->Get(aTraceHeaderKey, it);
}
return bytes;
}
int
IndexMap::Add(const std::string &aTraceHeaderKey,
const std::string &aTraceHeaderValue,
const size_t &aBytePosition) {
this->mIndexMap[aTraceHeaderKey][aTraceHeaderValue].push_back(aBytePosition);
return BS_BASE_RC_SUCCESS;
}
int
IndexMap::Add(const std::string &aTraceHeaderKey,
const std::string &aTraceHeaderValue,
const std::vector<size_t> &aBytePositions) {
int rc = 0;
for (auto const &it : aBytePositions) {
rc += this->Add(aTraceHeaderKey, aTraceHeaderValue, it);
}
/* Check that all Add() functions returned BS_BASE_RC_SUCCESS signal. */
return aBytePositions.empty() ? BS_BASE_RC_SUCCESS : (rc / aBytePositions.size()) == BS_BASE_RC_SUCCESS;
}
| 2,107
|
C++
|
.cpp
| 55
| 34.581818
| 108
| 0.711698
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,229
|
FileIndexer.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/indexers/FileIndexer.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/indexers/FileIndexer.hpp>
#include <bs/io/lookups/mappers/SegyHeaderMapper.hpp>
#include <bs/io/utils/convertors/NumbersConvertor.hpp>
#include <bs/io/configurations/MapKeys.h>
using namespace bs::base::exceptions;
using namespace bs::io::indexers;
using namespace bs::io::dataunits;
using namespace bs::io::lookups;
using namespace bs::io::streams::helpers;
using namespace bs::io::utils::convertors;
FileIndexer::FileIndexer(std::string &aFilePath,
std::string &aKey)
: mInFilePath(aFilePath),
mOutFilePath(GenerateOutFilePathName(aFilePath, aKey)) {
this->mInStreamHelper = nullptr;
}
FileIndexer::~FileIndexer() {
delete this->mInStreamHelper;
}
size_t
FileIndexer::Initialize() {
this->mInStreamHelper = new InStreamHelper(this->mInFilePath);
return (this->mInStreamHelper->Open());
}
int
FileIndexer::Finalize() {
return (this->mInStreamHelper->Close());
}
std::string
FileIndexer::GenerateOutFilePathName(std::string &aInFileName,
std::string &key) {
return aInFileName.substr(0,
aInFileName.size() - std::string(IO_K_EXT_SGY).length())
+ key
+ IO_K_EXT_SGY_INDEX;
}
IndexMap
FileIndexer::Index(const std::vector<TraceHeaderKey> &aTraceHeaderKeys) {
std::string key = TraceHeaderKey::GatherKeysToString(aTraceHeaderKeys);
std::string expected_file_path = GenerateOutFilePathName(this->mInFilePath,
key);
auto in = new InStreamHelper(this->mOutFilePath);
bool already_indexed = true;
try {
in->Open();
} catch (FileNotFoundException &e) {
already_indexed = false;
}
if (!already_indexed) {
/* Read binary header in the given file.*/
auto bhl = this->mInStreamHelper->ReadBinaryHeader(IO_POS_S_BINARY_HEADER);
unsigned long long file_size = this->mInStreamHelper->GetFileSize();
size_t start_pos = IO_POS_S_TRACE_HEADER;
while (true) {
if (start_pos + IO_SIZE_TRACE_HEADER >= file_size) {
break;
}
/* Read trace header in the given file. */
auto thl = this->mInStreamHelper->ReadTraceHeader(start_pos);
std::unordered_map<dataunits::TraceHeaderKey::Key,
std::pair<size_t, NATIVE_TYPE>> location_table;
for (const auto &thk :aTraceHeaderKeys) {
TraceHeaderKey trh = thk;
dataunits::TraceHeaderKey::Key k = trh.GetKey();
std::pair<size_t, NATIVE_TYPE> offset_type = SegyHeaderMapper::mLocationTable[k];
location_table[k] = offset_type;
}
Trace trace(0);
HeaderMapper::MapHeaderToTrace(
(const char *) &thl, trace, location_table, true);
auto &map = *trace.GetTraceHeaders();
std::vector<std::string> values;
values.reserve(aTraceHeaderKeys.size());
for (const auto &it : aTraceHeaderKeys) {
values.push_back(map.find(it)->second);
}
std::string value = TraceHeaderKey::GatherValuesToString(values);
this->mIndexMap.Add(key, value, start_pos);
/* Update stream position pointer. */
start_pos += IO_SIZE_TRACE_HEADER + InStreamHelper::GetTraceDataSize(thl, bhl);
}
/** store index map */
StoreMapToFile(aTraceHeaderKeys);
} else {
/** load index map */
LoadMapFromFile(in, aTraceHeaderKeys);
in->Close();
}
delete in;
return this->mIndexMap;
}
void
FileIndexer::StoreMapToFile(const std::vector<TraceHeaderKey> &aTraceHeaderKeys) {
std::string key = TraceHeaderKey::GatherKeysToString(aTraceHeaderKeys);
auto out_helper = new OutStreamHelper(this->mOutFilePath);
out_helper->Open();
/** store length of IndexMap Key */
size_t key_size = key.size();
out_helper->WriteBytesBlock((const char *) &key_size, sizeof(size_t));
/** store index map key */
out_helper->WriteBytesBlock(key.c_str(), key_size);
/** Get map of unique values and vector of byte positions */
std::map<std::string, std::vector<size_t>> unique_values_map = this->mIndexMap.Get(key);
/** store map size */
size_t map_size = unique_values_map.size();
out_helper->WriteBytesBlock((const char *) &map_size, sizeof(size_t));
for (const auto &it : unique_values_map) {
/** store length of each unique key string */
size_t unique_key_size = it.first.size();
out_helper->WriteBytesBlock((const char *) &unique_key_size, sizeof(size_t));
/** store unique key */
out_helper->WriteBytesBlock(it.first.c_str(), unique_key_size);
/** store sizeof vector of byte positions */
size_t bytes_vector_size = it.second.size();
out_helper->WriteBytesBlock((const char *) &bytes_vector_size, sizeof(size_t));
/** loop on the vector and store each byte position */
for (const auto &byte : it.second) {
out_helper->WriteBytesBlock((const char *) &byte, sizeof(size_t));
}
}
out_helper->Close();
delete out_helper;
}
void
FileIndexer::LoadMapFromFile(streams::helpers::InStreamHelper *aInStreamHelper,
const std::vector<dataunits::TraceHeaderKey> &aTraceHeaderKeys) {
size_t position = 0;
/** load index map key length */
size_t key_size;
auto buffer = aInStreamHelper->ReadBytesBlock(position, sizeof(size_t));
std::memcpy(&key_size, buffer, sizeof(size_t));
position += sizeof(size_t);
delete[] buffer;
/** load index map key */
auto idx_map_key = aInStreamHelper->ReadBytesBlock(position, key_size);
std::string key(&idx_map_key[0], idx_map_key + key_size);
position += key_size;
delete[] idx_map_key;
/** load map of unique values and byte positions' vector size */
size_t map_size;
buffer = aInStreamHelper->ReadBytesBlock(position, sizeof(size_t));
std::memcpy(&map_size, buffer, sizeof(size_t));
position += sizeof(size_t);
delete[] buffer;
for (int i = 0; i < map_size; i++) {
/** Load length of each unique key string */
size_t value_size;
buffer = aInStreamHelper->ReadBytesBlock(position, sizeof(size_t));
std::memcpy(&value_size, buffer, sizeof(size_t));
position += sizeof(size_t);
delete[] buffer;
/** Load unique key */
auto temp = aInStreamHelper->ReadBytesBlock(position, value_size);
std::string value(&temp[0], temp + value_size);
position += value_size;
delete[] temp;
/** Load sizeof vector of byte positions */
size_t bytes_vector_size;
buffer = aInStreamHelper->ReadBytesBlock(position, sizeof(size_t));
std::memcpy(&bytes_vector_size, buffer, sizeof(size_t));
position += sizeof(size_t);
delete[] buffer;
/** loop on the vector and load each byte position */
std::vector<size_t> byte_positions;
byte_positions.reserve(bytes_vector_size);
for (int j = 0; j < bytes_vector_size; j++) {
size_t byte_position;
buffer = aInStreamHelper->ReadBytesBlock(position, sizeof(size_t));
std::memcpy(&byte_position, buffer, sizeof(size_t));
byte_positions.push_back(byte_position);
position += sizeof(size_t);
delete[] buffer;
}
/** Add unique value and the vector of byte positions to the Index map */
this->mIndexMap.Add(key, value, byte_positions);
}
}
| 8,512
|
C++
|
.cpp
| 197
| 35.57868
| 97
| 0.641168
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,230
|
SeismicFilesHeaders.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/lookups/SeismicFilesHeaders.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/io/lookups/SeismicFilesHeaders.hpp>
using namespace bs::io::lookups;
using namespace bs::io::dataunits;
using namespace bs::io::utils::range;
const std::map<TraceHeaderKey, EntryRange> SeismicFilesHeaders::mTraceHeadersMap = {
{TraceHeaderKey::TRACL, EntryRange(EntryRange::Type::UINT, 0)},
{TraceHeaderKey::TRACR, EntryRange(EntryRange::Type::UINT, 4)},
{TraceHeaderKey::FLDR, EntryRange(EntryRange::Type::UINT, 8)},
{TraceHeaderKey::TRACF, EntryRange(EntryRange::Type::UINT, 12)},
{TraceHeaderKey::EP, EntryRange(EntryRange::Type::UINT, 16)},
{TraceHeaderKey::CDP, EntryRange(EntryRange::Type::UINT, 20)},
{TraceHeaderKey::CDPT, EntryRange(EntryRange::Type::UINT, 24)},
{TraceHeaderKey::TRID, EntryRange(EntryRange::Type::SHORT, 28)},
{TraceHeaderKey::NVS, EntryRange(EntryRange::Type::SHORT, 30)},
{TraceHeaderKey::NHS, EntryRange(EntryRange::Type::SHORT, 32)},
{TraceHeaderKey::DUSE, EntryRange(EntryRange::Type::SHORT, 34)},
{TraceHeaderKey::OFFSET, EntryRange(EntryRange::Type::UINT, 36)},
{TraceHeaderKey::GELEV, EntryRange(EntryRange::Type::UINT, 40)},
{TraceHeaderKey::SELEV, EntryRange(EntryRange::Type::UINT, 44)},
{TraceHeaderKey::SDEPTH, EntryRange(EntryRange::Type::UINT, 48)},
{TraceHeaderKey::GDEL, EntryRange(EntryRange::Type::UINT, 52)},
{TraceHeaderKey::SDEL, EntryRange(EntryRange::Type::UINT, 56)},
{TraceHeaderKey::SWDEP, EntryRange(EntryRange::Type::UINT, 60)},
{TraceHeaderKey::GWDEP, EntryRange(EntryRange::Type::UINT, 64)},
{TraceHeaderKey::SCALEL, EntryRange(EntryRange::Type::SHORT, 68)},
{TraceHeaderKey::SCALCO, EntryRange(EntryRange::Type::SHORT, 70)},
{TraceHeaderKey::SX, EntryRange(EntryRange::Type::UINT, 72)},
{TraceHeaderKey::SY, EntryRange(EntryRange::Type::UINT, 76)},
{TraceHeaderKey::GX, EntryRange(EntryRange::Type::UINT, 80)},
{TraceHeaderKey::GY, EntryRange(EntryRange::Type::UINT, 84)},
{TraceHeaderKey::COINTIT, EntryRange(EntryRange::Type::SHORT, 88)},
{TraceHeaderKey::WEVEL, EntryRange(EntryRange::Type::SHORT, 90)},
{TraceHeaderKey::SWEVEL, EntryRange(EntryRange::Type::SHORT, 92)},
{TraceHeaderKey::SUT, EntryRange(EntryRange::Type::SHORT, 94)},
{TraceHeaderKey::GUT, EntryRange(EntryRange::Type::SHORT, 96)},
{TraceHeaderKey::SSTAT, EntryRange(EntryRange::Type::SHORT, 98)},
{TraceHeaderKey::GSTAT, EntryRange(EntryRange::Type::SHORT, 100)},
{TraceHeaderKey::TSTAT, EntryRange(EntryRange::Type::SHORT, 102)},
{TraceHeaderKey::LAGA, EntryRange(EntryRange::Type::SHORT, 104)},
{TraceHeaderKey::LAGB, EntryRange(EntryRange::Type::SHORT, 106)},
{TraceHeaderKey::DELRT, EntryRange(EntryRange::Type::SHORT, 108)},
{TraceHeaderKey::MUTS, EntryRange(EntryRange::Type::SHORT, 110)},
{TraceHeaderKey::MUTE, EntryRange(EntryRange::Type::SHORT, 112)},
{TraceHeaderKey::NS, EntryRange(EntryRange::Type::USHORT, 114)},
{TraceHeaderKey::DT, EntryRange(EntryRange::Type::USHORT, 116)},
{TraceHeaderKey::GAIN, EntryRange(EntryRange::Type::SHORT, 118)},
{TraceHeaderKey::IGC, EntryRange(EntryRange::Type::SHORT, 120)},
{TraceHeaderKey::IGI, EntryRange(EntryRange::Type::SHORT, 122)},
{TraceHeaderKey::CORR, EntryRange(EntryRange::Type::SHORT, 124)},
{TraceHeaderKey::SFS, EntryRange(EntryRange::Type::SHORT, 126)},
{TraceHeaderKey::SFE, EntryRange(EntryRange::Type::SHORT, 128)},
{TraceHeaderKey::SLEN, EntryRange(EntryRange::Type::SHORT, 130)},
{TraceHeaderKey::STYP, EntryRange(EntryRange::Type::SHORT, 132)},
{TraceHeaderKey::STAS, EntryRange(EntryRange::Type::SHORT, 134)},
{TraceHeaderKey::STAE, EntryRange(EntryRange::Type::SHORT, 136)},
{TraceHeaderKey::TATYP, EntryRange(EntryRange::Type::SHORT, 138)},
{TraceHeaderKey::AFILF, EntryRange(EntryRange::Type::SHORT, 140)},
{TraceHeaderKey::AFILS, EntryRange(EntryRange::Type::SHORT, 142)},
{TraceHeaderKey::NOFILF, EntryRange(EntryRange::Type::SHORT, 144)},
{TraceHeaderKey::NOFILS, EntryRange(EntryRange::Type::SHORT, 146)},
{TraceHeaderKey::LCF, EntryRange(EntryRange::Type::SHORT, 148)},
{TraceHeaderKey::HCF, EntryRange(EntryRange::Type::SHORT, 150)},
{TraceHeaderKey::LCS, EntryRange(EntryRange::Type::SHORT, 152)},
{TraceHeaderKey::HCS, EntryRange(EntryRange::Type::SHORT, 154)},
{TraceHeaderKey::YEAR, EntryRange(EntryRange::Type::SHORT, 156)},
{TraceHeaderKey::DAY, EntryRange(EntryRange::Type::SHORT, 158)},
{TraceHeaderKey::HOUR, EntryRange(EntryRange::Type::SHORT, 160)},
{TraceHeaderKey::MINUTE, EntryRange(EntryRange::Type::SHORT, 162)},
{TraceHeaderKey::SEC, EntryRange(EntryRange::Type::SHORT, 164)},
{TraceHeaderKey::TIMBAS, EntryRange(EntryRange::Type::SHORT, 166)},
{TraceHeaderKey::TRWF, EntryRange(EntryRange::Type::SHORT, 168)},
{TraceHeaderKey::GRNORS, EntryRange(EntryRange::Type::SHORT, 170)},
{TraceHeaderKey::GRNOFR, EntryRange(EntryRange::Type::SHORT, 172)},
{TraceHeaderKey::GRNLOF, EntryRange(EntryRange::Type::SHORT, 174)},
{TraceHeaderKey::GAPS, EntryRange(EntryRange::Type::SHORT, 176)},
{TraceHeaderKey::OTRAV, EntryRange(EntryRange::Type::SHORT, 178)},
{TraceHeaderKey::ENSX, EntryRange(EntryRange::Type::UINT, 180)},
{TraceHeaderKey::ENSY, EntryRange(EntryRange::Type::UINT, 184)},
{TraceHeaderKey::INLINE, EntryRange(EntryRange::Type::UINT, 188)},
{TraceHeaderKey::CROSS, EntryRange(EntryRange::Type::UINT, 192)},
{TraceHeaderKey::SHOOTPOINT, EntryRange(EntryRange::Type::UINT, 196)},
{TraceHeaderKey::SHOOTPOINT_SCALE, EntryRange(EntryRange::Type::SHORT, 200)},
{TraceHeaderKey::TRACE_UNIT, EntryRange(EntryRange::Type::SHORT, 202)},
{TraceHeaderKey::TRANSD_CONST, EntryRange(EntryRange::Type::CHAR, 204, 6)},
{TraceHeaderKey::TRANSD_UNIT, EntryRange(EntryRange::Type::SHORT, 210)},
{TraceHeaderKey::TRID, EntryRange(EntryRange::Type::SHORT, 212)},
{TraceHeaderKey::SCALE_TIME, EntryRange(EntryRange::Type::SHORT, 214)},
{TraceHeaderKey::SRC_ORIENT, EntryRange(EntryRange::Type::SHORT, 216, 6)},
{TraceHeaderKey::SRC_DIRECTION, EntryRange(EntryRange::Type::CHAR, 218, 6)},
{TraceHeaderKey::SRC_MEASUREMT, EntryRange(EntryRange::Type::CHAR, 224, 6)},
{TraceHeaderKey::SRC_UNIT, EntryRange(EntryRange::Type::SHORT, 230)},
{TraceHeaderKey::UNASSIGNED1, EntryRange(EntryRange::Type::CHAR, 232, 6)}
};
| 8,417
|
C++
|
.cpp
| 111
| 68.369369
| 88
| 0.615273
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,231
|
HeaderMapper.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/lookups/mappers/HeaderMapper.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/exceptions/Exceptions.hpp>
#include <bs/io/lookups/mappers/HeaderMapper.hpp>
#include <bs/io/utils/convertors/NumbersConvertor.hpp>
using namespace bs::io::lookups;
using namespace bs::io::utils::convertors;
void
HeaderMapper::MapHeaderToTrace(const char *apRawData, io::dataunits::Trace &aTrace,
std::unordered_map<dataunits::TraceHeaderKey::Key, std::pair<size_t, NATIVE_TYPE>>
&aLocationTable,
bool aSwap) {
for (auto &it : aLocationTable) {
dataunits::TraceHeaderKey::Key key = it.first;
size_t offset = it.second.first;
NATIVE_TYPE type = it.second.second;
const char *cur_data = (apRawData + offset);
switch (type) {
case NATIVE_TYPE::CHAR:
case NATIVE_TYPE::UNSIGNED_CHAR:
aTrace.SetTraceHeaderKeyValue(key, *cur_data);
break;
case NATIVE_TYPE::SHORT:
case NATIVE_TYPE::UNSIGNED_SHORT: {
short s = *((short *) (cur_data));
if (aSwap) {
s = NumbersConvertor::ToLittleEndian(s);
}
aTrace.SetTraceHeaderKeyValue(key, s);
}
break;
case NATIVE_TYPE::INT:
case NATIVE_TYPE::UNSIGNED_INT: {
int i = *((int *) (cur_data));
if (aSwap) {
i = NumbersConvertor::ToLittleEndian(i);
}
aTrace.SetTraceHeaderKeyValue(key, i);
}
break;
case NATIVE_TYPE::LONG:
case NATIVE_TYPE::UNSIGNED_LONG: {
long l = *((long *) (cur_data));
if (aSwap) {
// l = NumbersConvertor::ToLittleEndian(l);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
aTrace.SetTraceHeaderKeyValue(key, l);
}
break;
case NATIVE_TYPE::FLOAT: {
float f = *((float *) (cur_data));
if (aSwap) {
// f = NumbersConvertor::ToLittleEndian(f);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
aTrace.SetTraceHeaderKeyValue(key, f);
}
break;
case NATIVE_TYPE::DOUBLE: {
double d = *((double *) (cur_data));
if (aSwap) {
// d = NumbersConvertor::ToLittleEndian(d);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
aTrace.SetTraceHeaderKeyValue(key, d);
}
break;
}
}
}
void
HeaderMapper::MapTraceToHeader(char *apRawData, io::dataunits::Trace &aTrace,
std::unordered_map<dataunits::TraceHeaderKey::Key, std::pair<size_t, NATIVE_TYPE>> &aLocationTable,
bool aSwap) {
for (auto &it : aLocationTable) {
dataunits::TraceHeaderKey::Key key = it.first;
size_t offset = it.second.first;
NATIVE_TYPE type = it.second.second;
char *cur_data = (apRawData + offset);
switch (type) {
case NATIVE_TYPE::CHAR:
case NATIVE_TYPE::UNSIGNED_CHAR: {
char c = 0;
if (aTrace.HasTraceHeader(key)) {
c = aTrace.GetTraceHeaderKeyValue<char>(key);
}
*cur_data = c;
}
break;
case NATIVE_TYPE::SHORT:
case NATIVE_TYPE::UNSIGNED_SHORT: {
short s = 0;
if (aTrace.HasTraceHeader(key)) {
s = aTrace.GetTraceHeaderKeyValue<short>(key);
}
if (aSwap) {
s = NumbersConvertor::ToLittleEndian(s);
}
*((short *) (cur_data)) = s;
}
break;
case NATIVE_TYPE::INT:
case NATIVE_TYPE::UNSIGNED_INT: {
int i = 0;
if (aTrace.HasTraceHeader(key)) {
i = aTrace.GetTraceHeaderKeyValue<int>(key);
}
if (aSwap) {
i = NumbersConvertor::ToLittleEndian(i);
}
*((int *) (cur_data)) = i;
}
break;
case NATIVE_TYPE::LONG:
case NATIVE_TYPE::UNSIGNED_LONG: {
int l = 0;
if (aTrace.HasTraceHeader(key)) {
l = aTrace.GetTraceHeaderKeyValue<long>(key);
}
if (aSwap) {
// l = NumbersConvertor::ToLittleEndian(l);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
*((long *) (cur_data)) = l;
}
break;
case NATIVE_TYPE::FLOAT: {
float f = 0;
if (aTrace.HasTraceHeader(key)) {
f = aTrace.GetTraceHeaderKeyValue<float>(key);
}
if (aSwap) {
// f = NumbersConvertor::ToLittleEndian(f);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
*((float *) (cur_data)) = f;
}
break;
case NATIVE_TYPE::DOUBLE: {
double d = 0;
if (aTrace.HasTraceHeader(key)) {
d = aTrace.GetTraceHeaderKeyValue<double>(key);
}
if (aSwap) {
// d = NumbersConvertor::ToLittleEndian(d);
throw bs::base::exceptions::UNSUPPORTED_FEATURE_EXCEPTION();
}
*((double *) (cur_data)) = d;
}
break;
}
}
}
size_t
bs::io::lookups::native_type_to_size(NATIVE_TYPE native_type) {
switch (native_type) {
case NATIVE_TYPE::CHAR:
return sizeof(char);
case NATIVE_TYPE::UNSIGNED_CHAR:
return sizeof(unsigned char);
case NATIVE_TYPE::SHORT:
return sizeof(short);
case NATIVE_TYPE::UNSIGNED_SHORT:
return sizeof(unsigned short);
case NATIVE_TYPE::LONG:
return sizeof(long);
case NATIVE_TYPE::UNSIGNED_LONG:
return sizeof(unsigned long);
case NATIVE_TYPE::INT:
return sizeof(int);
case NATIVE_TYPE::UNSIGNED_INT:
return sizeof(unsigned int);
case NATIVE_TYPE::FLOAT:
return sizeof(float);
case NATIVE_TYPE::DOUBLE:
return sizeof(double);
default:
return 0;
}
}
| 7,586
|
C++
|
.cpp
| 197
| 25.913706
| 130
| 0.507519
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,232
|
SegyHeaderMapper.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSIO/src/lookups/mappers/SegyHeaderMapper.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS I/O.
*
* BS I/O is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS I/O is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/io/lookups/mappers/SegyHeaderMapper.hpp>
using namespace bs::io::lookups;
using namespace bs::io::dataunits;
std::unordered_map<bs::io::dataunits::TraceHeaderKey::Key,
std::pair<size_t, NATIVE_TYPE>> SegyHeaderMapper::mLocationTable = {
{TraceHeaderKey::TRACL, {0, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::TRACR, {4, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::FLDR, {8, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::TRACF, {12, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::EP, {16, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::CDP, {20, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::CDPT, {24, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::TRACE_CODE, {28, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::NVS, {30, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::NHS, {32, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::DUSE, {34, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::OFFSET, {36, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::GELEV, {40, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SELEV, {44, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SDEPTH, {48, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::GDEL, {52, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SDEL, {56, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SWDEP, {60, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::GWDEP, {64, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SCALEL, {68, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SCALCO, {70, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SX, {72, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::SY, {76, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::GX, {80, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::GY, {84, NATIVE_TYPE::UNSIGNED_INT}},
{TraceHeaderKey::COINTIT, {88, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::WEVEL, {90, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SWEVEL, {92, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SUT, {94, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GUT, {96, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SSTAT, {98, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GSTAT, {100, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::TSTAT, {102, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::LAGA, {104, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::LAGB, {106, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::DELRT, {108, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::MUTS, {110, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::MUTE, {112, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::NS, {114, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::DT, {116, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GAIN, {118, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::IGC, {120, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::IGI, {122, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::CORR, {124, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SFS, {126, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SFE, {128, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SLEN, {130, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::STYP, {132, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::STAS, {134, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::STAE, {136, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::TATYP, {138, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::AFILF, {140, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::AFILS, {142, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::NOFILF, {144, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::NOFILS, {146, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::LCF, {148, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::HCF, {150, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::LCS, {152, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::HCS, {154, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::YEAR, {156, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::DAY, {158, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::HOUR, {160, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::MINUTE, {162, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::SEC, {164, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::TIMBAS, {166, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::TRWF, {168, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GRNORS, {170, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GRNOFR, {172, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GRNLOF, {174, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::GAPS, {176, NATIVE_TYPE::UNSIGNED_SHORT}},
{TraceHeaderKey::OTRAV, {178, NATIVE_TYPE::UNSIGNED_SHORT}},
};
| 6,215
|
C++
|
.cpp
| 95
| 58.136842
| 76
| 0.621158
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,233
|
main.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/examples/end-to-end/omp/main.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fstream>
#include <iostream>
#include <sys/stat.h>
#include <bs/timer/api/cpp/BSTimer.hpp>
#define SIZE 1000
using namespace std;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::reporter;
void
test_function();
int main() {
mkdir(BS_TIMER_WRITE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int grid_size = SIZE * SIZE;
int operations = 4 * 6 + 4; /* Floating point operations in sqrt() = 6 */
float a1[SIZE][SIZE];
for (int t = 0; t < 80; t++) {
ScopeTimer st("A_Kernel_OMP", grid_size, 1, true, operations);
test_function();
}
float a2[SIZE][SIZE];
for (int t = 0; t < 80; t++) {
ScopeTimer st("B_Kernel_OMP");
test_function();
}
std::vector < std::ostream * > streams;
streams.emplace_back(&std::cout);
std::ofstream ofs;
ofs.open(BS_TIMER_WRITE_PATH
"/timing_results.txt");
streams.emplace_back(&ofs);
TimerManager::GetInstance()->Report(streams);
ofs.close();
TimerManager::GetInstance()->Terminate(true);
return EXIT_SUCCESS;
}
inline void
test_function() {
float array[SIZE][SIZE];
#pragma omp parallel for
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
array[i][j] = sqrt(i) * sqrt(j) * sqrt(i) * sqrt(j);
}
}
}
| 2,097
|
C++
|
.cpp
| 64
| 29
| 77
| 0.667491
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,234
|
main.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/examples/end-to-end/serial/main.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fstream>
#include <iostream>
#include <sys/stat.h>
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <bs/timer/api/cpp/BSTimer.hpp>
#include <bs/timer/common/Definitions.hpp>
#define SIZE 1000
using namespace std;
using namespace bs::base::configurations;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::reporter;
void
test_function();
int main() {
mkdir(BS_TIMER_WRITE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
nlohmann::json map;
map[BS_TIMER_K_PROPERTIES][BS_TIMER_K_TIME_UNIT] = 1e-3;
auto configuration_map = new JSONConfigurationMap(map);
TimerManager::GetInstance()->Configure(configuration_map);
int grid_size = SIZE * SIZE;
int operations = 4 * 6 + 4; /* Floating point operations in sqrt() = 6*/
cout << "Lazy Timer (Serial)" << endl;
core::LazyTimer::Evaluate([&]() {
test_function();
}, true);
for (int i = 0; i < 80; i++) {
ScopeTimer t("A_Kernel_Serial", grid_size, 1, true, operations);
test_function();
}
for (int i = 0; i < 10; i++) {
ScopeTimer st("B_Kernel_Serial");
test_function();
}
std::vector<std::ostream *> streams;
streams.emplace_back(&std::cout);
std::ofstream ofs;
ofs.open(BS_TIMER_WRITE_PATH
"/timing_results.txt");
streams.emplace_back(&ofs);
TimerManager::GetInstance()->Report(streams);
ofs.close();
TimerManager::GetInstance()->Terminate(true);
return EXIT_SUCCESS;
}
inline void
test_function() {
float array[SIZE][SIZE];
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
array[i][j] = sqrt(i) * sqrt(j) * sqrt(i) * sqrt(j);
}
}
}
| 2,516
|
C++
|
.cpp
| 72
| 30.902778
| 76
| 0.675319
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,235
|
TestTimer.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/core/TestTimer.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <chrono>
#include <prerequisites/libraries/catch/catch.hpp>
#include <bs/base/common/ExitCodes.hpp>
#include <bs/timer/core/timers/concrete/ElasticTimer.hpp>
#include <bs/timer/configurations/TimerManager.hpp>
#include <bs/timer/test-utils/FunctionsGenerator.hpp>
using namespace std;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::testutils;
TEST_CASE("Timer - Class", "[Core]") {
/* Pre-cleanup. */
TimerManager::Kill();
/* Meta-data. */
int grid_size = 1000 * 1000;
int data_size = grid_size * sizeof(float);
int operations = 4 * 6 + 4; /* Floating point operations in sqrt() = 6*/
TimerChannel channel("First Kernel", grid_size, data_size, operations);
TimerChannel::Pointer channel_pointer = std::make_shared<TimerChannel>(channel);
TimerManager::GetInstance()->RegisterChannel(channel_pointer);
ElasticTimer timer("First Kernel", grid_size, 1, true, operations);
REQUIRE(timer.Start() == BS_BASE_RC_SUCCESS);
REQUIRE(timer.Start() == BS_BASE_RC_FAILURE);
REQUIRE(timer.IsActive() == true);
timer.Start();
timer.Stop();
REQUIRE(timer.IsActive() == false);
auto start = chrono::high_resolution_clock::now();
timer.Start();
target_technology_test_function();
auto end = chrono::high_resolution_clock::now();
timer.Stop();
chrono::duration<double> elapsed_seconds = end - start;
channel_pointer->GetChannelStats().Resolve();
REQUIRE(channel_pointer->GetChannelStats().GetRuntimes()[0] == Approx(0).margin(0.1));
REQUIRE(channel_pointer->GetChannelStats().GetRuntimes()[1] == Approx(elapsed_seconds.count()).margin(0.00001));
/* Cleanup. */
TimerManager::GetInstance()->Terminate(true);
}
| 2,513
|
C++
|
.cpp
| 57
| 40.614035
| 116
| 0.722131
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,236
|
TestLazyTimer.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/core/TestLazyTimer.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
TEST_CASE("LazyTimer - Class", "[Core]") {
}
| 839
|
C++
|
.cpp
| 21
| 38
| 73
| 0.75092
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,237
|
TestStatisticsHelper.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/utils/TestStatisticsHelper.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vector>
#include <prerequisites/libraries/catch/catch.hpp>
#include <bs/timer/utils/stats/StatisticsHelper.hpp>
using namespace bs::timer::utils::stats;
TEST_CASE("Statistics Helper - Class", "[Utils]") {
SECTION("Long") {
std::vector<long> nums{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
REQUIRE(StatisticsHelper::GetMin(nums) == 1);
REQUIRE(StatisticsHelper::GetMax(nums) == 10);
REQUIRE(StatisticsHelper::GetAverage(nums) == 5.5);
REQUIRE(StatisticsHelper::GetVariance(nums) == 8.25);
REQUIRE(StatisticsHelper::GetDeviation(nums) == Approx(2.8723));
nums = {-190000000, -100000000, 100000000, -1000000000, 190000000,
280000000, 370000000, 460000000, 550000000, 640000000,
730000000, 820000000, 910000000, 1000000000};
REQUIRE(StatisticsHelper::GetMin(nums) == -1000000000);
REQUIRE(StatisticsHelper::GetMax(nums) == 1000000000);
REQUIRE(StatisticsHelper::GetAverage(nums) == 340000000);
REQUIRE(StatisticsHelper::GetVariance(nums) == Approx(2.6044285714286e+17));
REQUIRE(StatisticsHelper::GetDeviation(nums) == Approx(510336023.75578));
nums = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
REQUIRE(StatisticsHelper::GetMin(nums) == 0);
REQUIRE(StatisticsHelper::GetMax(nums) == 0);
REQUIRE(StatisticsHelper::GetAverage(nums) == 0);
REQUIRE(StatisticsHelper::GetVariance(nums) == 0);
REQUIRE(StatisticsHelper::GetDeviation(nums) == 0);
nums = {};
REQUIRE(StatisticsHelper::GetMin(nums) == 0);
REQUIRE(StatisticsHelper::GetMax(nums) == 0);
REQUIRE(StatisticsHelper::GetAverage(nums) == 0);
REQUIRE(StatisticsHelper::GetVariance(nums) == 0);
REQUIRE(StatisticsHelper::GetDeviation(nums) == 0);
}
SECTION("Double") {
std::vector<double> numsD = {0.000001, -0.000001, 1.1, 999999.99, -9999.9};
REQUIRE(StatisticsHelper::GetMin(numsD) == -9999.9);
REQUIRE(StatisticsHelper::GetMax(numsD) == 999999.99);
REQUIRE(StatisticsHelper::GetAverage(numsD) == Approx(198000.238));
REQUIRE(StatisticsHelper::GetVariance(numsD) == Approx(160815901352.19));
REQUIRE(StatisticsHelper::GetDeviation(numsD) == Approx(401018.5798092));
}
}
| 3,044
|
C++
|
.cpp
| 60
| 44.483333
| 84
| 0.682919
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,238
|
TestChannel.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/configurations/TestChannel.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <bs/timer/configurations/TimerChannel.hpp>
#include <bs/timer/configurations/TimerManager.hpp>
#include <bs/timer/core/timers/concrete/ElasticTimer.hpp>
using namespace bs::timer;
using namespace bs::timer::configurations;
TEST_CASE("TimerChannel - Class", "[Configuration]") {
/* Pre-cleanup. */
TimerManager::Kill();
/* Channel test. */
TimerChannel channel("FirstChannel", 1000, 1000, 9);
TimerChannel::Pointer channel_pointer = std::make_shared<TimerChannel>(channel);
configurations::TimerManager::GetInstance()->RegisterChannel(channel_pointer);
REQUIRE(channel.GetName() == "FirstChannel");
/* Timer test. */
ElasticTimer timer(channel_pointer);
REQUIRE(channel_pointer->GetTimers().size() == 1);
REQUIRE(channel_pointer->GetTimers()[0] == &timer);
/* Cleanup. */
TimerManager::GetInstance()->Terminate(true);
}
| 1,681
|
C++
|
.cpp
| 39
| 40.076923
| 84
| 0.740196
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,239
|
TestManager.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/configurations/TestManager.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <bs/timer/configurations/TimerManager.hpp>
#include <bs/timer/configurations/TimerChannel.hpp>
#include <bs/timer/core/timers/concrete/ElasticTimer.hpp>
using namespace bs::timer;
using namespace bs::timer::configurations;
TEST_CASE("TimerManager - Class", "[Configuration]") {
/* Pre-cleanup. */
TimerManager::Kill();
TimerChannel channel("FirstChannel", 1000, 1000, 9);
TimerChannel::Pointer channel_pointer = std::make_shared<TimerChannel>(channel);
TimerManager::GetInstance()->RegisterChannel(channel_pointer);
ElasticTimer timer1(channel_pointer);
ElasticTimer timer2(channel_pointer);
timer1.Start();
timer2.Start();
REQUIRE(TimerManager::GetInstance()->Get("FirstChannel") == channel_pointer);
REQUIRE(TimerManager::GetInstance()->GetActiveTimers().size() == 2);
timer2.Stop();
REQUIRE(TimerManager::GetInstance()->GetActiveTimers().size() == 1);
TimerManager::GetInstance()->Terminate(true);
REQUIRE(TimerManager::GetInstance()->GetActiveTimers().empty());
REQUIRE(TimerManager::GetInstance()->Get("FirstChannel") == nullptr);
/* Cleanup. */
TimerManager::GetInstance()->Terminate(true);
}
| 1,984
|
C++
|
.cpp
| 44
| 41.772727
| 84
| 0.743124
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,240
|
TestReporter.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/reporter/TestReporter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <prerequisites/libraries/catch/catch.hpp>
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <bs/timer/reporter/TimerReporter.hpp>
#include <bs/timer/core/timers/concrete/ElasticTimer.hpp>
#include <bs/timer/utils/stats/StatisticsHelper.hpp>
#include <bs/timer/test-utils/FunctionsGenerator.hpp>
#define TOLERANCE 0.0001 /* Based on trial and error */
using namespace std;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::reporter;
using namespace bs::timer::utils::stats;
using namespace bs::timer::testutils;
using namespace bs::base::configurations;
TEST_CASE("Reporter - Class", "[reporter]") {
/* Pre-cleanup. */
TimerManager::Kill();
/* Meta-data. */
nlohmann::json map;
map[BS_TIMER_K_TIME_UNIT] = "sec";
auto configuration_map = new JSONConfigurationMap(map);
TimerManager::GetInstance()->Configure(configuration_map);
double grid_size = 1000 * 1000;
double data_size = grid_size * sizeof(float);
int operations = 4 * 6 + 4; /* Floating point operations in sqrt() = 6*/
/* Timers' instantiation. */
TimerChannel channel("First Kernel", grid_size, data_size, operations);
TimerChannel::Pointer channel_pointer = std::make_shared<TimerChannel>(channel);
TimerManager::GetInstance()->RegisterChannel(channel_pointer);
ElasticTimer timer1(channel_pointer);
ElasticTimer timer2(channel_pointer);
/* Runtime storage vector. */
vector<double> runtimes;
/* Timer object test. */
timer1.Start();
timer1.Stop();
runtimes.push_back(0);
/* Chrono timer ground truth test. */
auto start = chrono::high_resolution_clock::now();
timer2.Start();
target_technology_test_function();
auto end = chrono::high_resolution_clock::now();
timer2.Stop();
chrono::duration<double> elapsed_seconds = end - start;
runtimes.push_back(elapsed_seconds.count());
/* Results. */
auto average = StatisticsHelper::GetAverage(runtimes);
auto total = StatisticsHelper::GetTotal(runtimes);
/* Reporter test. */
TimerReporter r;
r.Resolve();
REQUIRE(r.GetMap("First Kernel")[BS_TIMER_K_MIN_RUNTIME]
== Approx(0).margin(TOLERANCE));
REQUIRE(r.GetMap("First Kernel")[BS_TIMER_K_MAX_RUNTIME]
== Approx(elapsed_seconds.count()).margin(TOLERANCE));
REQUIRE(r.GetMap("First Kernel")[BS_TIMER_K_AVERAGE_RUNTIME]
== Approx(average).margin(TOLERANCE));
REQUIRE(r.GetMap("First Kernel")[BS_TIMER_K_TOTAL]
== Approx(total).margin(TOLERANCE));
REQUIRE(r.GetStats()["First Kernel"].GetNumberOfCalls()
== 2);
/* Cleanup. */
TimerManager::GetInstance()->Terminate(true);
}
| 3,528
|
C++
|
.cpp
| 83
| 38.180723
| 84
| 0.71299
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,241
|
FunctionsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/test-utils/src/FunctionsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/timer/test-utils/FunctionsGenerator.hpp>
#ifdef USE_OMP
#include "concrete/omp/OmpFunctionsGenerator.hpp"
#include "concrete/serial/SerialFunctionsGenerator.hpp"
#else
#include "concrete/serial/SerialFunctionsGenerator.hpp"
#endif
void
bs::timer::testutils::target_technology_test_function() {
#if USE_OMP
omp_test_function();
#else
serial_test_function();
#endif
}
void
bs::timer::testutils::test_function() {
serial_test_function();
}
| 1,210
|
C++
|
.cpp
| 37
| 30.702703
| 73
| 0.767382
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,242
|
OmpFunctionsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/test-utils/src/concrete/omp/OmpFunctionsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include "OmpFunctionsGenerator.hpp"
#include <cmath>
#define BS_TIMER_TESTS_ARRAY_SIZE 1000 /* Test array size definition. */
void
omp_internal_test_function() {
float array[BS_TIMER_TESTS_ARRAY_SIZE][BS_TIMER_TESTS_ARRAY_SIZE];
#pragma omp parallel for
for (int i = 0; i < BS_TIMER_TESTS_ARRAY_SIZE; i++) {
for (int j = 0; j < BS_TIMER_TESTS_ARRAY_SIZE; j++) {
array[i][j] = sqrt(i) * sqrt(j) * sqrt(i) * sqrt(j);
}
}
}
void
bs::timer::testutils::omp_test_function() {
omp_internal_test_function();
}
| 1,297
|
C++
|
.cpp
| 35
| 34.171429
| 77
| 0.705648
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,243
|
SerialFunctionsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/tests/test-utils/src/concrete/serial/SerialFunctionsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SerialFunctionsGenerator.hpp"
#include <cmath>
#define BS_TIMER_TESTS_ARRAY_SIZE 1000 /* Test array size definition. */
void
serial_internal_test_function() {
float array[BS_TIMER_TESTS_ARRAY_SIZE][BS_TIMER_TESTS_ARRAY_SIZE];
for (int i = 0; i < BS_TIMER_TESTS_ARRAY_SIZE; i++) {
for (int j = 0; j < BS_TIMER_TESTS_ARRAY_SIZE; j++) {
array[i][j] = sqrt(i) * sqrt(j) * sqrt(i) * sqrt(j);
}
}
}
void
bs::timer::testutils::serial_test_function() {
serial_internal_test_function();
}
| 1,283
|
C++
|
.cpp
| 34
| 34.823529
| 77
| 0.706024
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,244
|
OmpSnapshot.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/core/snapshots/concrete/omp/OmpSnapshot.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include "OmpSnapshot.hpp"
using namespace bs::timer::core::snapshots;
OmpSnapshot::OmpSnapshot(SnapshotTarget aSnapshotTarget) {}
OmpSnapshot::~OmpSnapshot() = default;
double
OmpSnapshot::Start() {
auto start = omp_get_wtime();
this->mStart = start;
return this->mStart;
}
double
OmpSnapshot::End() {
auto end = omp_get_wtime();
this->mEnd = end;
return this->mEnd;
}
double
OmpSnapshot::Resolve() {
return this->mEnd - this->mStart;
}
| 1,214
|
C++
|
.cpp
| 38
| 29.552632
| 73
| 0.73887
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,245
|
SerialSnapshot.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/core/snapshots/concrete/serial/SerialSnapshot.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/common/ExitCodes.hpp>
#include "SerialSnapshot.hpp"
using namespace bs::timer::core::snapshots;
SerialSnapshot::SerialSnapshot(SnapshotTarget aSnapshotTarget) {}
SerialSnapshot::~SerialSnapshot() = default;
double
SerialSnapshot::Start() {
auto start = std::chrono::high_resolution_clock::now();
this->mStartPoint = start;
/// @todo Check on status code
return BS_BASE_RC_SUCCESS;
}
double
SerialSnapshot::End() {
auto end = std::chrono::high_resolution_clock::now();
this->mEndPoint = end;
/// @todo Check on status code
return BS_BASE_RC_SUCCESS;
}
double
SerialSnapshot::Resolve() {
std::chrono::duration<double> runtime = this->mEndPoint - this->mStartPoint;
return runtime.count();
}
| 1,498
|
C++
|
.cpp
| 42
| 33.047619
| 80
| 0.743253
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,246
|
GenericSnapshot.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/core/snapshots/helpers/GenericSnapshot.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/timer/core/snapshots/helpers/GenericSnapshot.hpp>
#include "../concrete/serial/SerialSnapshot.hpp"
#ifdef USE_OMP
#include "../concrete/omp/OmpSnapshot.hpp"
#endif
using namespace bs::timer::core::snapshots;
GenericSnapshot::GenericSnapshot(SnapshotTarget aSnapshotTarget) {
#ifdef USE_OMP
this->mpSnapshot = new OmpSnapshot(aSnapshotTarget);
#else
this->mpSnapshot = new SerialSnapshot(aSnapshotTarget);
#endif
}
GenericSnapshot::~GenericSnapshot() {
delete this->mpSnapshot;
}
double
GenericSnapshot::Start() {
return this->mpSnapshot->Start();
}
double
GenericSnapshot::End() {
return this->mpSnapshot->End();
}
double
GenericSnapshot::Resolve() {
return this->mpSnapshot->Resolve();
}
| 1,478
|
C++
|
.cpp
| 46
| 29.978261
| 73
| 0.765493
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,247
|
ElasticTimer.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/core/timers/ElasticTimer.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/base/common/ExitCodes.hpp>
#include <bs/timer/core/timers/concrete/ElasticTimer.hpp>
#include <bs/timer/core/snapshots/helpers/GenericSnapshot.hpp>
#include <bs/timer/configurations/TimerManager.hpp>
using namespace std;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::core::snapshots;
ElasticTimer::ElasticTimer(const TimerChannel::Pointer &apChannel, SnapshotTarget aSnapshotTarget) {
TimerManager::GetInstance()->RegisterChannel(make_shared<TimerChannel>(*new TimerChannel(apChannel->GetName())));
this->mpSnapshot = new GenericSnapshot(aSnapshotTarget);
this->mpChannel = apChannel;
apChannel.get()->AddTimer(this);
this->mIsActive = false;
}
ElasticTimer::ElasticTimer(const char *apChannelName, SnapshotTarget aSnapshotTarget) {
TimerManager::GetInstance()->RegisterChannel(make_shared<TimerChannel>(*new TimerChannel(apChannelName)));
this->mpSnapshot = new GenericSnapshot(aSnapshotTarget);
this->mpChannel = configurations::TimerManager::GetInstance()->Get(apChannelName);
configurations::TimerManager::GetInstance()->Get(apChannelName).get()->AddTimer(this);
this->mIsActive = false;
}
ElasticTimer::ElasticTimer(const char *apChannelName,
int aGridSize,
int aArrays,
bool aSinglePrecision,
int aOperations,
SnapshotTarget aSnapshotTarget) {
int data_size;
if (aSinglePrecision) {
data_size = aArrays * aGridSize * 4;
} else {
data_size = aArrays * aGridSize * 8;
}
TimerManager::GetInstance()->RegisterChannel(
make_shared<TimerChannel>(*new TimerChannel(apChannelName, aGridSize, data_size, aOperations)));
this->mpSnapshot = new GenericSnapshot(aSnapshotTarget);
this->mpChannel = configurations::TimerManager::GetInstance()->Get(apChannelName);
configurations::TimerManager::GetInstance()->Get(apChannelName).get()->AddTimer(this);
this->mIsActive = false;
}
ElasticTimer::~ElasticTimer() {
this->mIsActive = false;
this->mpChannel->RemoveTimer(this);
this->mpSnapshot = nullptr;
}
int
ElasticTimer::Start() {
int rc = BS_BASE_RC_FAILURE;
if (!this->IsActive()) {
this->mIsActive = true;
this->mpSnapshot->Start();
rc = BS_BASE_RC_SUCCESS;
}
return rc;
}
int
ElasticTimer::Stop() {
int rc = BS_BASE_RC_FAILURE;
if (this->IsActive()) {
this->mpSnapshot->End();
this->FlushSnapshot();
this->mIsActive = false;
rc = BS_BASE_RC_SUCCESS;
}
return rc;
}
void
ElasticTimer::FlushSnapshot() {
this->mpChannel->AddSnapshot(this->mpSnapshot);
}
bool
ElasticTimer::IsActive() const {
return mIsActive;
}
| 3,568
|
C++
|
.cpp
| 93
| 33.322581
| 117
| 0.707479
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,248
|
ScopeTimer.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/core/timers/ScopeTimer.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <bs/timer/core/timers/concrete/ScopeTimer.hpp>
using namespace std;
using namespace bs::timer;
using namespace bs::timer::core::snapshots;
ScopeTimer::ScopeTimer(const TimerChannel::Pointer &apChannel, SnapshotTarget aSnapshotTarget) {
this->mElasticTimer = new ElasticTimer(apChannel, aSnapshotTarget);
this->Start();
}
ScopeTimer::ScopeTimer(const char *apChannelName, SnapshotTarget aSnapshotTarget) {
this->mElasticTimer = new ElasticTimer(apChannelName, aSnapshotTarget);
this->Start();
}
ScopeTimer::ScopeTimer(const char *apChannelName,
int aGridSize,
int aArrays,
bool aSinglePrecision,
int aOperations,
SnapshotTarget aSnapshotTarget) {
this->mElasticTimer = new ElasticTimer(apChannelName,
aGridSize,
aArrays,
aSinglePrecision,
aOperations,
aSnapshotTarget);
this->Start();
}
ScopeTimer::~ScopeTimer() {
this->mElasticTimer->Stop();
delete this->mElasticTimer;
}
int
ScopeTimer::Start() {
return this->mElasticTimer->Start();
}
int
ScopeTimer::Stop() {
return this->mElasticTimer->Stop();
}
void
ScopeTimer::FlushSnapshot() {
this->mElasticTimer->FlushSnapshot();
}
bool
ScopeTimer::IsActive() const {
return this->mElasticTimer->IsActive();
}
| 2,312
|
C++
|
.cpp
| 65
| 28.323077
| 96
| 0.657871
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,249
|
ChannelStats.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/data-units/ChannelStats.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <bs/timer/data-units/ChannelStats.hpp>
#define BS_TIMER_DU_GIGA (1024 * 1024 * 1024) /* Giga definition. */
using namespace std;
using namespace bs::timer::dataunits;
ChannelStats::ChannelStats() :
mGridSize(-1),
mDataSize(-1),
mFLOPS(-1),
mNumberOfCalls(0) {}
ChannelStats::~ChannelStats() {
this->mSnapshots.clear();
}
void
ChannelStats::AddRuntime(double aRuntime) {
this->mRuntimes.push_back(aRuntime);
if (this->mDataSize > 0) {
this->mBandwidths.push_back(this->mDataSize / aRuntime);
}
this->mNumberOfCalls++;
}
void
ChannelStats::AddSnapshot(core::snapshots::Snapshot *apSnapshot) {
this->mSnapshots.push_back(apSnapshot);
}
void
ChannelStats::Resolve() {
if (!mResolved) {
mResolved = true;
for (auto it : this->mSnapshots) {
this->AddRuntime(it->Resolve());
}
}
}
void
ChannelStats::SetGridSize(int aGridSize) {
this->mGridSize = aGridSize;
}
void
ChannelStats::SetDataSize(int aDataSize) {
this->mDataSize = aDataSize;
}
void
ChannelStats::SetFLOPS(int aFLOPS) {
this->mFLOPS = aFLOPS;
}
map<string, double>
ChannelStats::GetMap() {
mStatisticsMap[BS_TIMER_K_MIN_RUNTIME] = this->GetMinRuntime();
mStatisticsMap[BS_TIMER_K_MAX_RUNTIME] = this->GetMaxRuntime();
mStatisticsMap[BS_TIMER_K_AVERAGE_RUNTIME] = this->GetAverageRuntime();
mStatisticsMap[BS_TIMER_K_VARIANCE] = this->GetVariance();
mStatisticsMap[BS_TIMER_K_DEVIATION] = this->GetDeviation();
mStatisticsMap[BS_TIMER_K_TOTAL] = this->GetTotal();
if (this->mDataSize > 0) {
mStatisticsMap[BS_TIMER_K_MAX_BANDWIDTH] = this->GetMaxBandwidth();
mStatisticsMap[BS_TIMER_K_MIN_BANDWIDTH] = this->GetMinBandwidth();
mStatisticsMap[BS_TIMER_K_AVERAGE_BANDWIDTH] = this->GetAverageBandwidth();
}
if (this->mGridSize > 0) {
mStatisticsMap[BS_TIMER_K_MIN_THROUGHPUT] = this->GetMinThroughput();
mStatisticsMap[BS_TIMER_K_MAX_THROUGHPUT] = this->GetMaxThroughput();
mStatisticsMap[BS_TIMER_K_AVERAGE_THROUGHPUT] = this->GetAverageThroughput();
mStatisticsMap[BS_TIMER_K_MIN_GFLOPS] = this->GetMinGFLOPS();
mStatisticsMap[BS_TIMER_K_MAX_GFLOPS] = this->GetMaxGFLOPS();
mStatisticsMap[BS_TIMER_K_AVERAGE_GFLOPS] = this->GetAverageGFLOPS();
mStatisticsMap[BS_TIMER_K_OPERATIONS] = this->GetNumberOfOperations();
}
return this->mStatisticsMap;
}
double
ChannelStats::GetTotal() {
return utils::stats::StatisticsHelper::GetTotal(this->mRuntimes);
}
double
ChannelStats::GetMaxRuntime() {
return utils::stats::StatisticsHelper::GetMax(this->mRuntimes);
}
double
ChannelStats::GetMinRuntime() {
return utils::stats::StatisticsHelper::GetMin(this->mRuntimes);
}
double
ChannelStats::GetAverageRuntime() {
return utils::stats::StatisticsHelper::GetAverage(this->mRuntimes);
}
double
ChannelStats::GetVariance() {
return utils::stats::StatisticsHelper::GetVariance(this->mRuntimes);
}
double
ChannelStats::GetDeviation() {
return utils::stats::StatisticsHelper::GetDeviation(this->mRuntimes);
}
vector<double>
ChannelStats::GetRuntimes() {
return this->mRuntimes;
}
unsigned int
ChannelStats::GetNumberOfCalls() const {
return this->mNumberOfCalls;
}
int
ChannelStats::GetGridSize() const {
return this->mGridSize;
}
int
ChannelStats::GetDataSize() const {
return this->mDataSize;
}
double
ChannelStats::GetMaxBandwidth() {
return this->mDataSize / this->mStatisticsMap[BS_TIMER_K_MIN_RUNTIME];
}
double
ChannelStats::GetMinBandwidth() {
return this->mDataSize / this->mStatisticsMap[BS_TIMER_K_MAX_RUNTIME];
}
double
ChannelStats::GetAverageBandwidth() {
return this->mDataSize / this->mStatisticsMap[BS_TIMER_K_AVERAGE_RUNTIME];
}
double
ChannelStats::GetMaxThroughput() {
return this->mGridSize / this->mStatisticsMap[BS_TIMER_K_MIN_RUNTIME];
}
double
ChannelStats::GetMinThroughput() {
return this->mGridSize / this->mStatisticsMap[BS_TIMER_K_MAX_RUNTIME];
}
double
ChannelStats::GetAverageThroughput() {
return this->mGridSize / this->mStatisticsMap[BS_TIMER_K_AVERAGE_RUNTIME];
}
int
ChannelStats::GetNumberOfOperations() const {
return this->mGridSize * this->mFLOPS;
}
double
ChannelStats::GetMinGFLOPS() {
return (this->mGridSize * this->mFLOPS) / mStatisticsMap[BS_TIMER_K_MAX_RUNTIME] / BS_TIMER_DU_GIGA;
}
double
ChannelStats::GetMaxGFLOPS() {
return (this->mGridSize * this->mFLOPS) / mStatisticsMap[BS_TIMER_K_MIN_RUNTIME] / BS_TIMER_DU_GIGA;
}
double
ChannelStats::GetAverageGFLOPS() {
return (this->mGridSize * this->mFLOPS) / mStatisticsMap[BS_TIMER_K_AVERAGE_RUNTIME] / BS_TIMER_DU_GIGA;
}
vector<double>
ChannelStats::GetBandwidths() {
return this->mBandwidths;
}
| 5,574
|
C++
|
.cpp
| 172
| 29.197674
| 108
| 0.734489
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,250
|
TimerChannel.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/configurations/TimerChannel.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bs/timer/configurations/TimerChannel.hpp>
using namespace bs::timer;
using namespace bs::timer::dataunits;
TimerChannel::~TimerChannel() {
for (auto timer : this->mTimers) {
if (timer) {
timer = nullptr;
}
}
}
void
TimerChannel::AddTimer(Timer *aTimer) {
this->mTimers.push_back(aTimer);
}
void
TimerChannel::AddSnapshot(core::snapshots::Snapshot *apSnapshot) {
this->mChannelStats.AddSnapshot(apSnapshot);
}
ChannelStats &
TimerChannel::GetChannelStats() {
return this->mChannelStats;
}
void
TimerChannel::RemoveTimer(Timer *apTimer) {
auto it = this->mTimers.begin();
for (; it != this->mTimers.end();) {
if (*it == apTimer) {
it = this->mTimers.erase(it);
} else {
++it;
}
}
}
| 1,546
|
C++
|
.cpp
| 51
| 26.705882
| 73
| 0.698722
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,251
|
TimerManager.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/configurations/TimerManager.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <bs/base/common/ExitCodes.hpp>
#include <bs/timer/configurations/TimerManager.hpp>
#include <bs/timer/reporter/TimerReporter.hpp>
using namespace bs::timer;
using namespace bs::timer::core;
using namespace bs::timer::configurations;
using namespace bs::base::configurations;
void
TimerManager::Configure(ConfigurationMap *apConfigurationMap) {
this->mpConfigurationMap = apConfigurationMap;
this->AcquireConfiguration();
}
void
TimerManager::Terminate(bool aCleanup) {
for (const auto &channel : this->mChannelMap) {
if (channel.second != nullptr) {
for (auto timer : channel.second->GetTimers()) {
if (timer != nullptr) {
if (timer->IsActive()) {
timer->Stop();
}
}
}
}
}
if (aCleanup) {
this->Cleanup();
}
}
TimerChannel::Pointer
TimerManager::Get(const char *apChannelName) {
return this->mChannelMap[apChannelName];
}
void
TimerManager::Cleanup() {
this->mChannelMap.clear();
}
std::vector<Timer *>
TimerManager::GetActiveTimers() {
std::vector<bs::timer::Timer *> vec;
for (const auto &channel : this->mChannelMap) {
for (auto timer : channel.second->GetTimers()) {
if (timer->IsActive()) {
vec.push_back(timer);
}
}
}
return vec;
}
int
TimerManager::Report(const std::vector<std::ostream *> &aStreams, const std::string &aChannelName) {
int rc = BS_BASE_RC_SUCCESS;
for (auto stream : aStreams) {
rc += (this->Report(*stream, aChannelName)).empty() ? BS_BASE_RC_FAILURE : BS_BASE_RC_SUCCESS;
}
reporter::TimerReporter r;
rc += r.FlushReport(BS_TIMER_WRITE_PATH "/data" BS_TIMER_EXT);
return rc;
}
std::string
TimerManager::Report(std::ostream &aOutputStream, const std::string &aChannelName) {
reporter::TimerReporter r;
return r.GenerateStream(aOutputStream, aChannelName);
}
void
TimerManager::RegisterChannel(const TimerChannel::Pointer &apChannel) {
if (this->mChannelMap.count(apChannel->GetName()) == 0) {
/* New channel being registered. */
this->mChannelMap[apChannel->GetName()] = apChannel;
}
}
TimerChannel::Map
TimerManager::GetMap() {
return this->mChannelMap;
}
void
TimerManager::AcquireConfiguration() {
this->mTimePrecision = this->mpConfigurationMap->GetValue(BS_TIMER_K_PROPERTIES, BS_TIMER_K_TIME_UNIT, 1.0);
}
double
TimerManager::GetPrecision() {
return this->mTimePrecision;
}
| 3,317
|
C++
|
.cpp
| 102
| 28.009804
| 112
| 0.68793
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,252
|
TimerReporter.cpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSTimer/src/reporter/TimerReporter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Timer.
*
* BS Timer is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Timer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ostream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sys/stat.h>
#include <bs/base/common/ExitCodes.hpp>
#include <bs/timer/reporter/TimerReporter.hpp>
#include <bs/timer/common/Definitions.hpp>
#define BS_TIMER_DU_MEGA (1024 * 1024) /* Mega definition. */
#define BS_TIMER_DU_GIGA (1024 * 1024 * 1024) /* Giga definition. */
using namespace std;
using namespace bs::timer;
using namespace bs::timer::configurations;
using namespace bs::timer::dataunits;
using namespace bs::timer::reporter;
TimerReporter::TimerReporter() {
for (const auto &channel : TimerManager::GetInstance()->GetMap()) {
this->mDataMap[channel.first] = channel.second->GetChannelStats();
}
}
map<string, double>
TimerReporter::GetMap(const std::string &aChannelName) {
return this->mDataMap[aChannelName].GetMap();
}
void
TimerReporter::Resolve() {
for (auto &channel: this->mDataMap) {
channel.second.Resolve();
}
}
std::string
TimerReporter::GenerateStream(std::ostream &aOutputStream, const std::string &aChannelName) {
string val;
auto precision = TimerManager::GetInstance()->GetPrecision();
string unit = TimerReporter::PrecisionToUnit(precision);
if (aChannelName == " ") {
string report;
for (const auto &channel: this->mDataMap) {
report += GenerateStream(aOutputStream, channel.first);
}
val = report;
aOutputStream << val;
} else {
this->mDataMap[aChannelName].Resolve();
std::stringstream os;
auto stats = this->mDataMap[aChannelName].GetMap();
os.precision(5);
os << std::endl;
os << left << setfill(' ') << setw(20) << "Function Name" << ": "
<< left << setfill(' ') << setw(20) << aChannelName << std::endl;
os << left << setfill(' ') << setw(20) << "Number of Calls" << ": "
<< left << setfill(' ') << setw(20)
<< std::fixed << this->mDataMap[aChannelName].GetNumberOfCalls() << std::endl;
os << left << setfill(' ') << setw(20) << "Maximum Runtime" << ": "
<< left << setfill(' ') << setw(12)
<< std::scientific << stats[BS_TIMER_K_MAX_RUNTIME] / precision
<< left << unit << "\n";
os << left << setfill(' ') << setw(20) << "Minimum Runtime" << ": "
<< left << setfill(' ') << setw(12)
<< std::scientific << stats[BS_TIMER_K_MIN_RUNTIME] / precision << unit << std::endl;
os << left << setfill(' ') << setw(20) << "Average Runtime" << ": "
<< left << setfill(' ') << setw(12)
<< std::scientific << stats[BS_TIMER_K_AVERAGE_RUNTIME] / precision << unit << std::endl;
os << left << setfill(' ') << setw(20) << "Total Runtime" << ": "
<< left << setfill(' ') << setw(12)
<< std::scientific << stats[BS_TIMER_K_TOTAL] / precision << unit << std::endl;
if (this->mDataMap[aChannelName].GetDataSize() > 0) {
os << left << setfill(' ') << setw(20) << "Size of Data" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << (double) this->mDataMap[aChannelName].GetDataSize() / BS_TIMER_DU_MEGA;
os << " Mpts" << std::endl
<< left << setfill(' ') << setw(20) << "Maximum Bandwidth" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MAX_BANDWIDTH] / BS_TIMER_DU_GIGA;
os << " GBytes/s" << std::endl
<< left << setfill(' ') << setw(20) << "Minimum Bandwidth" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MIN_BANDWIDTH] / BS_TIMER_DU_GIGA;
os << " GBytes/s" << std::endl
<< left << setfill(' ') << setw(20) << "Average Bandwidth" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_AVERAGE_BANDWIDTH] / BS_TIMER_DU_GIGA
<< " GBytes/s" << std::endl;
}
if (this->mDataMap[aChannelName].GetGridSize() > 0) {
os << left << setfill(' ') << setw(20) << "Grid Size" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << (double) this->mDataMap[aChannelName].GetGridSize() / BS_TIMER_DU_MEGA
<< " Mpts" << std::endl;
os << left << setfill(' ') << setw(20) << "Maximum Throughput" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MAX_THROUGHPUT] / BS_TIMER_DU_MEGA
<< " Mpts/s" << std::endl;
os << left << setfill(' ') << setw(20) << "Minimum Throughput" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MIN_THROUGHPUT] / BS_TIMER_DU_MEGA
<< " Mpts/s" << std::endl;
os << left << setfill(' ') << setw(20) << "Average Throughput" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_AVERAGE_THROUGHPUT] / BS_TIMER_DU_MEGA
<< " Mpts/s" << std::endl;
os << left << setfill(' ') << setw(20) << "Maximum GFLops" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MAX_GFLOPS]
<< " GFLOPS" << std::endl;
os << left << setfill(' ') << setw(20) << "Minimum GFlops" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_MIN_GFLOPS]
<< " GFLOPS" << std::endl;
os << left << setfill(' ') << setw(20) << "Average GFlops" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_AVERAGE_GFLOPS]
<< " GFLOPS" << std::endl;
os << left << setfill(' ') << setw(20) << "Number of Operations" << ": "
<< left << setfill(' ') << setw(11)
<< std::scientific << stats[BS_TIMER_K_OPERATIONS] << std::endl;
}
val = os.str();
}
return val;
}
int
TimerReporter::FlushReport(const std::string &aFilePath) {
TimerReporter::HandleFilePath(aFilePath);
std::ofstream os = std::ofstream(aFilePath, std::ios::out | std::ios::binary);
if (!os) {
std::cerr << "Error: Cannot open file!" << std::endl;
return BS_BASE_RC_FAILURE;
}
auto channels_count = TimerManager::GetInstance()->GetMap().size();
os.write(reinterpret_cast<char *>(&channels_count),
sizeof(int)); /* Number of kernels reported. (4 bytes)*/
for (auto channel : this->mDataMap) {
/* Resolve channel first to be able to fetch data correctly. */
channel.second.Resolve();
auto stats = channel.second.GetMap();
auto size = channel.first.size();
os.write(reinterpret_cast<char *>(&size), sizeof(unsigned)); /* Size of kernel name. (4 bytes) */
os.write(channel.first.c_str(), size * sizeof(char)); /* Kernel name (variable)*/
auto runtimes = channel.second.GetRuntimes();
size = runtimes.size();
os.write(reinterpret_cast<char *>(&size),
sizeof(unsigned)); /* Number of calls for this kernel/ size of arrays(4 byte)*/
os.write(reinterpret_cast<char *>(&runtimes[0]),
size * sizeof(double)); /* Array of runtimes (variable)*/
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_MAX_RUNTIME]),
sizeof(double));
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_MIN_RUNTIME]),
sizeof(double));
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_AVERAGE_RUNTIME]),
sizeof(double));
unsigned char flag;
if (channel.second.GetDataSize() > 0) {
flag = 1;
os.write(reinterpret_cast<char *>(&flag),
sizeof(unsigned char));
auto bandwidths = channel.second.GetBandwidths();
os.write(reinterpret_cast<char *>(&bandwidths[0]),
size * sizeof(double)); /*Array of bandwidths (variable) */
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_MAX_BANDWIDTH]),
sizeof(double));
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_MIN_BANDWIDTH]),
sizeof(double));
os.write(reinterpret_cast<char *>(&stats[BS_TIMER_K_AVERAGE_BANDWIDTH]),
sizeof(double));
} else {
flag = 0;
os.write(reinterpret_cast<char *>(&flag),
sizeof(unsigned char));
}
}
os.close();
return BS_BASE_RC_SUCCESS;
}
int
TimerReporter::HandleFilePath(const std::string &aFilePath) {
auto directory = aFilePath;
auto pos = directory.rfind('/');
if (pos != string::npos) {
directory.erase(directory.begin() + pos, directory.end());
}
return mkdir(directory.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}
map<std::string, ChannelStats>
TimerReporter::GetStats() {
return this->mDataMap;
}
std::string
TimerReporter::PrecisionToUnit(double aPrecision) {
string unit;
if (aPrecision == BS_TIMER_TU_MILLI) {
unit = BS_TIMER_TU_STR_MILLI;
} else if (aPrecision == BS_TIMER_TU_MICRO) {
unit = BS_TIMER_TU_STR_MICRO;
} else if (aPrecision == BS_TIMER_TU_NANO) {
unit = BS_TIMER_TU_STR_NANO;
} else {
unit = BS_TIMER_TU_STR_SEC;
}
return unit;
}
| 10,392
|
C++
|
.cpp
| 219
| 38.630137
| 108
| 0.56017
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,253
|
TestGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/generators/TestGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <stbx/generators/Generator.hpp>
#include <stbx/generators/primitive/CallbacksGenerator.hpp>
#include <stbx/generators/concrete/computation-parameters/computation_parameters_generator.h>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <stbx/test-utils/utils.h>
using namespace std;
using namespace bs::base::exceptions;
using namespace bs::base::configurations;
using namespace stbx::agents;
using namespace stbx::writers;
using namespace stbx::generators;
using namespace stbx::testutils;
using namespace operations::configurations;
using namespace operations::common;
using namespace operations::helpers::callbacks;
using namespace operations::components;
void TEST_CASE_GENERATOR() {
nlohmann::json ground_truth_map = R"(
{
"callbacks": {
"writer": {
"active-types": [
{
"su": {
"properties": {
"write-little-endian": false
}
}
},
{
"csv": {
"properties": {
}
}
},
{
"image": {
"properties": {
"percentile": 98.5
}
}
},
{
"binary": {
"properties": {
}
}
},
{
"segy": {
"properties": {
}
}
}
],
"enable": true,
"show-each": 200
},
"norm": {
"enable": true,
"show-each": 200
},
"writers-configuration": {
"migration": {
"enable": true
},
"parameters": {
"enable": true,
"list": ["velocity", "density"]
},
"traces-raw": {
"enable": true
},
"traces-preprocessed": {
"enable": true
},
"re-extended-parameters": {
"enable": true,
"list": ["velocity", "density"]
},
"each-stacked-shot": {
"enable": true
},
"single-shot-correlation": {
"enable": true
},
"backward": {
"enable": true
},
"forward": {
"enable": true
},
"reverse": {
"enable": true
}
}
},
"computation-parameters": {
"stencil-order": 8,
"boundary-length": 20,
"source-frequency": 20,
"isotropic-radius": 5,
"dt-relax": 0.9,
"algorithm": "cpu",
"device": "none",
"cache-blocking": {
"block-x": 128,
"block-z": 16,
"block-y": 1
},
"window": {
"enable": true,
"left": 250,
"right": 250,
"depth": 500,
"front": 0,
"back": 0
}
},
"traces": {
"min": 601,
"max": 601,
"sort-type": "CSR",
"paths": [
"data/iso/shots/shots0601_0800.segy"
]
},
"models": {
"velocity": "data/iso/params/vel_z6.25m_x12.5m_exact.segy"
},
"wave": {
"physics": "acoustic",
"approximation": "isotropic",
"equation-order": "second",
"grid-sampling": "uniform"
},
"components": {
"boundary-manager": {
"type": "none",
"properties": {
"use-top-layer": false,
"grain-side-length": 200
}
},
"migration-accommodator": {
"type": "cross-correlation",
"properties": {
"compensation": "no"
}
},
"forward-collector": {
"type": "three"
},
"trace-manager": {
"properties": {
"type": "segy",
"shot-stride": 2,
"interpolation": "none",
"header-only": false
}
},
"source-injector": {
"type": "ricker"
},
"model-handler": {
"properties": {
"type": "segy"
}
},
"trace-writer": {
"properties": {
"type": "segy",
"output-file": "data/synthetic_model_traces"
}
}
},
"interpolation": {
"type": "none"
},
"system": {
"agent": {
"type": "normal"
},
"writer": {
"type": "normal"
}
}
}
)"_json;
auto *generator = new Generator(ground_truth_map);
SECTION("Instance not null") {
REQUIRE(instanceof<Generator>(generator));
REQUIRE(generator != nullptr);
}
SECTION("GenerateCallbacks Function Testing") {
REQUIRE(instanceof<CallbackCollection>(generator->GenerateCallbacks(WRITE_PATH)));
}
SECTION("GenerateModellingEngineConfiguration Function Testing") {
auto *configuration = generator->GenerateModellingEngineConfiguration(WRITE_PATH);
REQUIRE(instanceof<ModellingEngineConfigurations>(configuration));
REQUIRE(instanceof<ComputationKernel>(configuration->GetComputationKernel()));
REQUIRE(instanceof<ModelHandler>(configuration->GetModelHandler()));
REQUIRE(instanceof<SourceInjector>(configuration->GetSourceInjector()));
REQUIRE(instanceof<BoundaryManager>(configuration->GetBoundaryManager()));
REQUIRE(instanceof<TraceManager>(configuration->GetTraceManager()));
REQUIRE(instanceof<TraceWriter>(configuration->GetTraceWriter()));
}
SECTION("GenerateParameters Function Testing") {
auto *computationParameters = generator->GenerateParameters();
REQUIRE(instanceof<ComputationParameters>(computationParameters));
REQUIRE(computationParameters->GetBoundaryLength() == 20);
REQUIRE(computationParameters->GetRelaxedDT() == 0.9f);
REQUIRE(computationParameters->GetSourceFrequency() == 20);
REQUIRE(computationParameters->IsUsingWindow() == true);
REQUIRE(computationParameters->GetLeftWindow() == 250);
REQUIRE(computationParameters->GetRightWindow() == 250);
REQUIRE(computationParameters->GetDepthWindow() == 500);
REQUIRE(computationParameters->GetFrontWindow() == 0);
REQUIRE(computationParameters->GetBackWindow() == 0);
REQUIRE(computationParameters->GetEquationOrder() == SECOND);
REQUIRE(computationParameters->GetApproximation() == ISOTROPIC);
REQUIRE(computationParameters->GetPhysics() == ACOUSTIC);
REQUIRE(computationParameters->GetBlockX() == 128);
REQUIRE(computationParameters->GetBlockY() == 1);
REQUIRE(computationParameters->GetBlockZ() == 16);
}
SECTION("GenerateRTMConfiguration Function Testing") {
RTMEngineConfigurations *configuration = generator->GenerateRTMConfiguration(WRITE_PATH);
REQUIRE(instanceof<ComputationKernel>(configuration->GetComputationKernel()));
REQUIRE(instanceof<ModelHandler>(configuration->GetModelHandler()));
REQUIRE(instanceof<SourceInjector>(configuration->GetSourceInjector()));
REQUIRE(instanceof<BoundaryManager>(configuration->GetBoundaryManager()));
REQUIRE(instanceof<ForwardCollector>(configuration->GetForwardCollector()));
REQUIRE(instanceof<MigrationAccommodator>(configuration->GetMigrationAccommodator()));
REQUIRE(instanceof<TraceManager>(configuration->GetTraceManager()));
}
SECTION("GenerateAgent Function Testing") {
Agent *agent = generator->GenerateAgent();
REQUIRE(instanceof<Agent>(agent));
}
SECTION("GenerateWriter Function Testing") {
Writer *writer = generator->GenerateWriter();
REQUIRE(instanceof<Writer>(writer));
}
}
TEST_CASE("Generator Class Testing", "[Generators]") {
TEST_CASE_GENERATOR();
}
| 8,182
|
C++
|
.cpp
| 267
| 24.11236
| 97
| 0.622687
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,254
|
TestComputationParametersGetter.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/generators/primitive/TestComputationParametersGetter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <stbx/generators/primitive/ComputationParametersGetter.hpp>
using namespace stbx::generators;
void TEST_CASE_BASE_COMPUTATION_PARAMETERS_GETTER() {
nlohmann::json map = R"(
{
"stencil-order": 8,
"boundary-length": 20,
"source-frequency": 20,
"isotropic-radius": 5,
"dt-relax": 0.9,
"algorithm": "cpu",
"Device": "none",
"cache-blocking": {
"block-x": 5500,
"block-z": 55,
"block-y": 1
}
}
)"_json;
auto computation_parameters_getter = new ComputationParametersGetter(map);
SECTION("GetBoundaryLength Testing") {
REQUIRE(computation_parameters_getter->GetBoundaryLength() == 20);
}
SECTION("GetSourceFrequency Testing") {
REQUIRE(computation_parameters_getter->GetSourceFrequency() == 20.0);
}
SECTION("GetDTRelaxed Testing") {
REQUIRE(computation_parameters_getter->GetDTRelaxed() == 0.9f);
}
SECTION("GetBlock Testing") {
REQUIRE(computation_parameters_getter->GetBlock("x") == 5500);
REQUIRE(computation_parameters_getter->GetBlock("y") == 1);
REQUIRE(computation_parameters_getter->GetBlock("z") == 55);
}
SECTION("GetIsotropicCircle Testing") {
REQUIRE(computation_parameters_getter->GetIsotropicCircle() == 5);
}
delete computation_parameters_getter;
}
void TEST_CASE_STENCIL_ORDER_GETTER() {
SECTION("stencil-order = 2") {
nlohmann::json map = R"(
{"stencil-order": 2}
)"_json;
auto *computation_parameters_getter = new ComputationParametersGetter(map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
REQUIRE(so.order == 2);
REQUIRE(so.half_length == O_2);
}
SECTION("stencil-order = 4") {
nlohmann::json map = R"(
{"stencil-order": 4}
)"_json;
auto *computation_parameters_getter = new ComputationParametersGetter(map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
REQUIRE(so.order == 4);
REQUIRE(so.half_length == O_4);
}
SECTION("stencil-order = 8") {
nlohmann::json map = R"(
{"stencil-order": 8}
)"_json;
auto *computation_parameters_getter = new ComputationParametersGetter(map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
REQUIRE(so.order == 8);
REQUIRE(so.half_length == O_8);
}
SECTION("stencil-order = 12") {
nlohmann::json map = R"(
{"stencil-order": 12}
)"_json;
auto *computation_parameters_getter = new ComputationParametersGetter(map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
REQUIRE(so.order == 12);
REQUIRE(so.half_length == O_12);
}
SECTION("stencil-order = 16") {
nlohmann::json map = R"(
{"stencil-order": 16}
)"_json;
auto *computation_parameters_getter = new ComputationParametersGetter(map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
REQUIRE(so.order == 16);
REQUIRE(so.half_length == O_16);
}
}
void TEST_CASE_WINDOW_GETTER() {
/// Average test cases parameter
nlohmann::json average_map = R"(
{
"window": {
"enable": true,
"left": 250,
"right": 250,
"depth": 500,
"front": 0,
"back": 0}
}
)"_json;
/// Minimum test cases parameter
nlohmann::json min_map = R"(
{
"window": {
"enable": true,
"left": -10,
"right": -10,
"depth": -10,
"front": -10,
"back": -10}
}
)"_json;
/// Null test cases parameter
nlohmann::json null_map = R"(
{
"window": {
"enable": false}
}
)"_json;
/// Missing test cases parameter
nlohmann::json missing_map = R"(
{
"window": {
"enable": true}
}
)"_json;
SECTION("Average Case") {
auto computation_parameters_getter = new ComputationParametersGetter(average_map);
auto w = computation_parameters_getter->GetWindow();
REQUIRE(w.use_window == 1);
REQUIRE(w.left_win == 250);
REQUIRE(w.right_win == 250);
REQUIRE(w.depth_win == 500);
REQUIRE(w.front_win == 0);
REQUIRE(w.back_win == 0);
delete computation_parameters_getter;
}
SECTION("Minimum Case") {
auto computation_parameters_getter = new ComputationParametersGetter(min_map);
auto w = computation_parameters_getter->GetWindow();
REQUIRE(w.use_window == 1);
REQUIRE(w.left_win == DEF_VAL);
REQUIRE(w.right_win == DEF_VAL);
REQUIRE(w.depth_win == DEF_VAL);
REQUIRE(w.front_win == DEF_VAL);
REQUIRE(w.back_win == DEF_VAL);
delete computation_parameters_getter;
}
SECTION("Null Case") {
auto computation_parameters_getter = new ComputationParametersGetter(null_map);
auto w = computation_parameters_getter->GetWindow();
REQUIRE(w.use_window == 0);
REQUIRE(w.left_win == DEF_VAL);
REQUIRE(w.right_win == DEF_VAL);
REQUIRE(w.depth_win == DEF_VAL);
REQUIRE(w.front_win == DEF_VAL);
REQUIRE(w.back_win == DEF_VAL);
delete computation_parameters_getter;
}
SECTION("missing values") {
auto computation_parameters_getter = new ComputationParametersGetter(missing_map);
auto w = computation_parameters_getter->GetWindow();
REQUIRE(w.use_window == 1);
REQUIRE(w.left_win == DEF_VAL);
REQUIRE(w.right_win == DEF_VAL);
REQUIRE(w.depth_win == DEF_VAL);
REQUIRE(w.front_win == DEF_VAL);
REQUIRE(w.back_win == DEF_VAL);
delete computation_parameters_getter;
}
}
TEST_CASE("ComputationParametersGetter Class - Base",
"[Generator],[ComputationParametersGetter]") {
TEST_CASE_BASE_COMPUTATION_PARAMETERS_GETTER();
}
TEST_CASE("ComputationParametersGetter Class - Stencil Order",
"[Generator],[ComputationParametersGetter]") {
TEST_CASE_STENCIL_ORDER_GETTER();
}
TEST_CASE("ComputationParametersGetter Class - Window Getter",
"[Generator],[ComputationParametersGetter]") {
TEST_CASE_WINDOW_GETTER();
}
| 7,142
|
C++
|
.cpp
| 202
| 29.019802
| 90
| 0.639965
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,255
|
TestConfigurationsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/generators/primitive/TestConfigurationsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
using namespace std;
using namespace stbx::generators;
void TEST_CASE_CONFIGURATIONS_GENERATOR() {
SECTION("WaveGetter") {
nlohmann::json map = R"(
{
"wave": {
"physics": "acoustic",
"approximation": "isotropic",
"equation-order": "first",
"grid-sampling": "uniform"
}
}
)"_json;
auto *configurations_generator = new ConfigurationsGenerator(map);
SECTION("GetPhysics Function Testing") {
PHYSICS physics = configurations_generator->GetPhysics();
REQUIRE(physics == ACOUSTIC);
}
SECTION("GetEquationOrder Function Testing") {
EQUATION_ORDER order = configurations_generator->GetEquationOrder();
REQUIRE(order == FIRST);
}
SECTION("GetGridSampling Function Testing") {
GRID_SAMPLING sampling = configurations_generator->GetGridSampling();
REQUIRE(sampling == UNIFORM);
}
SECTION("GetApproximation") {
APPROXIMATION approximation = configurations_generator->GetApproximation();
REQUIRE(approximation == ISOTROPIC);
}
}
SECTION("FileGetter Function Testing") {
nlohmann::json map = R"(
{
"traces": {
"min": 0,
"max": 601,
"sort-type": "CSR",
"paths": [
"path test"
]
},
"models": {
"velocity": "velocity test",
"density": "density test",
"delta": "delta test",
"epsilon": "epsilon test",
"theta": "theta test",
"phi": "phi test"
},
"modelling-file": "modelling-file test",
"output-file": "output-file test",
"wave": {
"physics": "acoustic",
"approximation": "isotropic",
"equation-order": "first",
"grid-sampling": "uniform"
}
}
)"_json;
auto *configurations_generator = new ConfigurationsGenerator(map);
SECTION("GetModelFiles Function Testing") {
std::map<string, string> model_files = configurations_generator->GetModelFiles();
REQUIRE(model_files["velocity"] == "velocity test");
REQUIRE(model_files["density"] == "density test");
REQUIRE(model_files["delta"] == "delta test");
REQUIRE(model_files["theta"] == "theta test");
REQUIRE(model_files["phi"] == "phi test");
}
SECTION("GetTraceFiles Function Testing") {
vector<string> traces_files = configurations_generator->GetTraceFiles();
REQUIRE(configurations_generator->GetTracesMin() == 0);
REQUIRE(configurations_generator->GetTracesMax() == 601);
REQUIRE(configurations_generator->GetTracesSortKey() == "CSR");
REQUIRE(traces_files.back() == "path test");
}
}
}
TEST_CASE("ConfigurationsGenerator", "[Generator],[ConfigurationsGenerator]") {
TEST_CASE_CONFIGURATIONS_GENERATOR();
}
| 3,784
|
C++
|
.cpp
| 103
| 30.514563
| 93
| 0.654664
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,256
|
TestComponentsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/generators/primitive/TestComponentsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string>
#include <prerequisites/libraries/catch/catch.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <stbx/generators/primitive/ComponentsGenerator.hpp>
#include <stbx/test-utils/utils.h>
using namespace bs::base::exceptions;
using namespace bs::base::configurations;
using namespace stbx::generators;
using namespace stbx::testutils;
using namespace operations::common;
using namespace operations::components;
void TEST_CASE_COMPONENTS_GENERATOR() {
nlohmann::json map = R"(
{
"boundary-manager": {
"type": "none",
"properties": {
"use-top-layer": false
}
},
"migration-accommodator": {
"type": "cross-correlation",
"properties": {
"compensation": "no"
}
},
"forward-collector": {
"type": "three"
},
"trace-manager": {
"type": "segy",
"properties": {
"shot-stride" : 2
}
},
"source-injector": {
"type": "ricker"
},
"model-handler": {
"type": "segy"
},
"trace-writer": {
"type": "binary"
},
"modelling-configuration-parser": {
"type": "text"
}
}
)"_json;
APPROXIMATION approximation = ISOTROPIC;
EQUATION_ORDER order = SECOND;
GRID_SAMPLING sampling = UNIFORM;
auto components_generator = new ComponentsGenerator(map, order, sampling, approximation);
SECTION("GenerateComputationKernel") {
auto computation_kernel = components_generator->GenerateComputationKernel();
REQUIRE(instanceof<ComputationKernel>(computation_kernel));
delete computation_kernel;
}
SECTION("GenerateModelHandler") {
auto model_handler = components_generator->GenerateModelHandler();
REQUIRE(instanceof<ModelHandler>(model_handler));
delete model_handler;
}
SECTION("GenerateSourceInjector") {
auto source_injector = components_generator->GenerateSourceInjector();
REQUIRE(instanceof<SourceInjector>(source_injector));
delete source_injector;
}
SECTION("GenerateBoundaryManager") {
auto boundary_manager = components_generator->GenerateBoundaryManager();
REQUIRE(instanceof<BoundaryManager>(boundary_manager));
delete boundary_manager;
}
SECTION("GenerateForwardCollector") {
auto forward_collector = components_generator->GenerateForwardCollector(WRITE_PATH);
REQUIRE(instanceof<ForwardCollector>(forward_collector));
}
SECTION("GenerateMigrationAccommodator") {
auto migration_accommodator = components_generator->GenerateMigrationAccommodator();
REQUIRE(instanceof<MigrationAccommodator>(migration_accommodator));
}
SECTION("GenerateTraceManager") {
auto trace_manager = components_generator->GenerateTraceManager();
REQUIRE(instanceof<TraceManager>(trace_manager));
delete trace_manager;
}
SECTION("GenerateTraceWriter") {
auto trace_writer = components_generator->GenerateTraceWriter();
REQUIRE(instanceof<TraceWriter>(trace_writer));
delete trace_writer;
}
}
TEST_CASE("ComponentsGenerator Class", "[Generator],[ComponentsGenerator]") {
TEST_CASE_COMPONENTS_GENERATOR();
}
| 3,999
|
C++
|
.cpp
| 113
| 30.185841
| 93
| 0.704422
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,257
|
utils.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/test-utils/src/utils.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stbx/test-utils/utils.h>
| 794
|
C++
|
.cpp
| 19
| 39.842105
| 76
| 0.763566
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,258
|
TestParser.cpp
|
brightskiesinc_Reverse_Time_Migration/tests/parsers/TestParser.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <prerequisites/libraries/catch/catch.hpp>
#include <stbx/parsers/Parser.hpp>
#include <stbx/test-utils/utils.h>
using namespace std;
using json = nlohmann::json;
using namespace stbx::parsers;
using namespace stbx::testutils;
void TEST_CASE_PARSER() {
SECTION("Register Files Function Test") {
auto *parser = Parser::GetInstance();
string parameter_file =
STBX_TEST_DATA_PATH "/workloads/computation_parameters.json";
string configuration_file =
STBX_TEST_DATA_PATH "/workloads/engine_configuration.json";
string callback_file =
STBX_TEST_DATA_PATH "/workloads/callback_configuration.json";
string pipeline =
STBX_TEST_DATA_PATH "/workloads/pipeline.json";
json ground_truth_map = R"(
{
"callbacks": {
"bin": {
"enable": true,
"show-each": 200
},
"csv": {
"enable": true,
"show-each": 200
},
"image": {
"enable": true,
"percentile": 98.5,
"show-each": 200
},
"norm": {
"enable": true,
"show-each": 200
},
"segy": {
"enable": true,
"show-each": 200
},
"su": {
"enable": true,
"little-endian": false,
"show-each": 200
},
"writers": {
"backward": {
"enable": true
},
"each-stacked-shot": {
"enable": true
},
"forward": {
"enable": true
},
"migration": {
"enable": true
},
"re-extended-velocity": {
"enable": true
},
"reverse": {
"enable": true
},
"single-shot-correlation": {
"enable": true
},
"traces-preprocessed": {
"enable": true
},
"traces-raw": {
"enable": true
},
"velocity": {
"enable": true
}
}
},
"components": {
"boundary-manager": {
"properties": {
"use-top-layer": false
},
"type": "none"
},
"forward-collector": {
"type": "three"
},
"migration-accommodator": {
"properties": {
"compensation": "no"
},
"type": "cross-correlation"
},
"model-handler": {
"type": "segy"
},
"source-injector": {
"type": "ricker"
},
"trace-manager": {
"properties": {
"shot-stride": 2
},
"type": "segy"
}
},
"computation-parameters": {
"algorithm": "cpu",
"boundary-length": 20,
"cache-blocking": {
"block-x": 5500,
"block-y": 1,
"block-z": 55
},
"device": "none",
"dt-relax": 0.9,
"isotropic-radius": 5,
"source-frequency": 20,
"stencil-order": 8,
"window": {
"back": 0,
"depth": 500,
"enable": true,
"front": 0,
"left": 250,
"right": 250
}
},
"interpolation": {
"type": "none"
},
"models": {
"velocity": "data/iso/params/vel_z6.25m_x12.5m_exact.segy"
},
"system": {
"agent": {
"type": "normal"
},
"writer": {
"type": "normal"
}
},
"traces": {
"max": 601,
"min": 601,
"paths": [
"data/iso/shots/shots0601_0800.segy"
],
"sort-type": "CSR"
},
"wave": {
"approximation": "isotropic",
"equation-order": "first",
"grid-sampling": "uniform",
"physics": "acoustic"
}
}
)"_json;
SECTION("GetInstance Function Test") {
REQUIRE(instanceof<Parser>(parser));
}
SECTION("RegisterFile & GetFiles Functions Test") {
parser->RegisterFile(parameter_file);
parser->RegisterFile(configuration_file);
parser->RegisterFile(callback_file);
parser->RegisterFile(pipeline);
vector<std::string> files = parser->GetFiles();
REQUIRE(std::find(files.begin(), files.end(), parameter_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), configuration_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), callback_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), pipeline) != files.end());
}
SECTION("BuildMap Function Test") {
json map = parser->BuildMap();
REQUIRE(map == ground_truth_map);
}
SECTION("GetMap Function Test") {
REQUIRE(parser->GetMap() == ground_truth_map);
}
SECTION("Parser Class Kill Function Test") {
REQUIRE(Parser::Kill() == nullptr);
}
}
SECTION("Register Folder Function Test") {
auto *parser = Parser::GetInstance();
string workloads =
STBX_TEST_DATA_PATH "/workloads/";
string parameter_file =
STBX_TEST_DATA_PATH "/workloads/computation_parameters.json";
string configuration_file =
STBX_TEST_DATA_PATH "/workloads/engine_configuration.json";
string callback_file =
STBX_TEST_DATA_PATH "/workloads/callback_configuration.json";
string pipeline =
STBX_TEST_DATA_PATH "/workloads/pipeline.json";
json ground_truth_map = R"(
{
"callbacks": {
"bin": {
"enable": true,
"show-each": 200
},
"csv": {
"enable": true,
"show-each": 200
},
"image": {
"enable": true,
"percentile": 98.5,
"show-each": 200
},
"norm": {
"enable": true,
"show-each": 200
},
"segy": {
"enable": true,
"show-each": 200
},
"su": {
"enable": true,
"little-endian": false,
"show-each": 200
},
"writers": {
"backward": {
"enable": true
},
"each-stacked-shot": {
"enable": true
},
"forward": {
"enable": true
},
"migration": {
"enable": true
},
"re-extended-velocity": {
"enable": true
},
"reverse": {
"enable": true
},
"single-shot-correlation": {
"enable": true
},
"traces-preprocessed": {
"enable": true
},
"traces-raw": {
"enable": true
},
"velocity": {
"enable": true
}
}
},
"components": {
"boundary-manager": {
"properties": {
"use-top-layer": false
},
"type": "none"
},
"forward-collector": {
"type": "three"
},
"migration-accommodator": {
"properties": {
"compensation": "no"
},
"type": "cross-correlation"
},
"model-handler": {
"type": "segy"
},
"source-injector": {
"type": "ricker"
},
"trace-manager": {
"properties": {
"shot-stride": 2
},
"type": "segy"
}
},
"computation-parameters": {
"algorithm": "cpu",
"boundary-length": 20,
"cache-blocking": {
"block-x": 5500,
"block-y": 1,
"block-z": 55
},
"device": "none",
"dt-relax": 0.9,
"isotropic-radius": 5,
"source-frequency": 20,
"stencil-order": 8,
"window": {
"back": 0,
"depth": 500,
"enable": true,
"front": 0,
"left": 250,
"right": 250
}
},
"interpolation": {
"type": "none"
},
"models": {
"velocity": "data/iso/params/vel_z6.25m_x12.5m_exact.segy"
},
"system": {
"agent": {
"type": "normal"
},
"writer": {
"type": "normal"
}
},
"traces": {
"max": 601,
"min": 601,
"paths": [
"data/iso/shots/shots0601_0800.segy"
],
"sort-type": "CSR"
},
"wave": {
"approximation": "isotropic",
"equation-order": "first",
"grid-sampling": "uniform",
"physics": "acoustic"
}
}
)"_json;
SECTION("GetInstance Function Test") {
REQUIRE(instanceof<Parser>(parser));
}
SECTION("RegisterFolder Function Test") {
parser->RegisterFolder(workloads);
vector<std::string> files = parser->GetFiles();
REQUIRE(std::find(files.begin(), files.end(), parameter_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), configuration_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), callback_file) != files.end());
REQUIRE(std::find(files.begin(), files.end(), pipeline) != files.end());
}
SECTION("BuildMap Function Test") {
json map = parser->BuildMap();
REQUIRE(map == ground_truth_map);
}
SECTION("GetMap Function Test") {
REQUIRE(parser->GetMap() == ground_truth_map);
}
SECTION("Parser Class Kill Function Test") {
REQUIRE(Parser::Kill() == nullptr);
}
}
}
TEST_CASE("Parser Class Tess", "[Parser]") {
TEST_CASE_PARSER();
}
| 9,600
|
C++
|
.cpp
| 385
| 18.335065
| 94
| 0.537005
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,259
|
DynamicServerAgent.cpp
|
brightskiesinc_Reverse_Time_Migration/src/agents/concrete/DynamicServerAgent.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(USING_MPI)
#include <mpi.h>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/agents/concrete/DynamicServerAgent.hpp>
using namespace std;
using namespace bs::base::logger;
using namespace stbx::agents;
using namespace operations::dataunits;
DynamicServerAgent::~DynamicServerAgent() {
for (auto it : this->mStacks) {
delete[] it;
}
}
GridBox *DynamicServerAgent::Initialize() {
LoggerSystem *Logger=LoggerSystem::GetInstance();
this->mpGridBox = mpEngine->Initialize();
int provided;
MPI_Init_thread(&this->argc, &this->argv, MPI_THREAD_FUNNELED, &provided);
if (provided != MPI_THREAD_FUNNELED) {
Logger->Error() << "Warning MPI did not provide MPI_THREAD_FUNNELED..." <<'\n';
}
this->mCommunication = MPI_COMM_WORLD;
MPI_Comm_rank(this->mCommunication, &this->self);
MPI_Comm_size(this->mCommunication, &this->mProcessCount);
return this->mpGridBox;
}
void DynamicServerAgent::BeforeMigration() {
if (this->self == 0) {
this->mPossibleShots = mpEngine->GetValidShots();
this->mShotsSize = this->mPossibleShots.size();
/*The server(process with rank 0) allocates the mig_flag to each client process:
0 for a process if (process rank < # of shots) -->it will be working on a shot.
1 if (process rank >=# of shots) -->there is no enough shots for this process.*/
for (int i = 1; i < this->mProcessCount; i++) {
//The process_rank >= number of shots
if (this->mShotsCount == this->mShotsSize) {
this->flag[4] = 1;
}
//process rank < # of shots
else {
this->mShotsCount++;
}
/*The server sends a mig_flag to each client process*/
MPI_Send(&this->flag[4], 1, MPI_INT, i, 20, this->mCommunication);
}
/*The server sends one shot ID to each client process that will be working on a shot. */
for (int i = 0; i < min<int>(this->mProcessCount - 1, this->mShotsSize); ++i) {
this->flag[0] = this->mPossibleShots[i];
MPI_Send(&this->flag[0], 1, MPI_INT, i + 1, 2, this->mCommunication);
/*The server updates the tracking of the coming shot ID to be processed*/
mShotTracker++;
}
} else {
/*Each client process receives the mig_flag form the client*/
MPI_Recv(&this->flag[4], 1, MPI_INT, 0, 20, this->mCommunication, &this->mStatus);
//Getting the valid shots.
vector<uint> temporary_shots;
temporary_shots = mpEngine->GetValidShots();
}
}
void DynamicServerAgent::AfterMigration() {
if (this->self == 0) {
while (this->mShotTracker < this->mShotsSize) {
for (int m = 0; m < this->mProcessCount - 1; ++m) {
/*The server is sending to all client processes a shot_flag of 0 which means there are still shots available*/
MPI_Send(&this->flag[1], 1, MPI_INT, m + 1, 3, this->mCommunication);
/*The server receives the av_flag and rank from the finished client*/
MPI_Recv(&this->flag[2], 2, MPI_INT, m + 1, 14, this->mCommunication, &this->mStatus);
/*If the av_flag equals 1*/
if (this->flag[2] == 1) {
this->flag[0] = this->mPossibleShots[mShotTracker];
int finished = this->flag[3];
/*The server sends the coming shot ID to be processed to the client who send the av_flag*/
MPI_Send(&this->flag[0], 1, MPI_INT, finished, 2, this->mCommunication);
/*The server updates the tracking of the coming shot ID to be processed*/
this->mShotTracker++;
}
/*If there are no shots available*/
if (this->mShotTracker == this->mShotsSize) {
//Break the loop
break;
}
}
}
/*As there are no shots available the shot_flag will be 1*/
flag[1] = 1;
/*The server sends to all client processes a shot_flag of 1*/
for (int i = 0; i < min<int>(this->mProcessCount - 1, this->mShotsSize); ++i) {
MPI_Send(&this->flag[1], 1, MPI_INT, i + 1, 3, this->mCommunication);
}
} else {
MPI_Recv(&this->flag[1], 1, MPI_INT, 0, 3, this->mCommunication, &this->mStatus);
if (this->flag[1] == 0) {
//Indicates that it is now available
this->flag[2] = 1;
//the current process rank
this->flag[3] = this->self;
// The client who finishes, sends av_flag (flag[2])
// to the server to state that it is now available.
// It sends also its rank to the server as an identification.
MPI_Send(&this->flag[2], 2, MPI_INT, 0, 14, this->mCommunication);
}
}
}
void DynamicServerAgent::BeforeFinalize() {}
MigrationData *DynamicServerAgent::AfterFinalize(MigrationData *apMigrationData) {
MigrationData *md = apMigrationData;
uint size = md->GetGridSize(X_AXIS) *
md->GetGridSize(Y_AXIS) *
md->GetGridSize(Z_AXIS) *
md->GetGatherDimension();
for (int i = 0; i < md->GetResults().size(); ++i) {
mStacks.push_back(new float[size]);
MPI_Reduce(md->GetResultAt(i)->GetData(), this->mStacks[i],
size, MPI_FLOAT, MPI_SUM, 0, this->mCommunication);
}
if (this->self == 0) {
for (int i = 0; i < md->GetResults().size(); ++i) {
md->SetResults(i, new Result(this->mStacks[i]));
}
}
MPI_Finalize();
if (this->self != 0) {
exit(0);
}
return md;
}
bool DynamicServerAgent::HasNextShot() {
if (this->self == 0) {
if (this->flag[1] == 0) {
return true;
} else {
return false;
}
} else {
if (this->flag[4] == 1) {
return false;
} else {
if (this->flag[1] == 0) {
/*Each client process receives the shot ID to work on from the server.*/
MPI_Recv(&this->flag[0], 1, MPI_INT, 0, 2, this->mCommunication, &this->mStatus);
return true;
} else {
return false;
}
}
}
}
vector<uint> DynamicServerAgent::GetNextShot() {
if (this->self == 0) {
this->mProcessShots.clear();
return this->mProcessShots;
} else {
this->mPossibleShots.clear();
this->mPossibleShots.push_back(this->flag[0]);
return this->mPossibleShots;
}
}
#endif
| 7,480
|
C++
|
.cpp
| 177
| 33.508475
| 126
| 0.589691
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,260
|
StaticServerlessAgent.cpp
|
brightskiesinc_Reverse_Time_Migration/src/agents/concrete/StaticServerlessAgent.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(USING_MPI)
#include <mpi.h>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/agents/concrete/StaticServerlessAgent.hpp>
using namespace std;
using namespace stbx::agents;
using namespace operations::dataunits;
using namespace bs::base::logger;
StaticServerlessAgent::StaticServerlessAgent() {
this->mCount = 0;
}
StaticServerlessAgent::~StaticServerlessAgent() {
for (auto it : this->mStacks) {
delete[] it;
}
}
GridBox *StaticServerlessAgent::Initialize() {
LoggerSystem *Logger=LoggerSystem::GetInstance();
this->mpGridBox = mpEngine->Initialize();
int provided;
MPI_Init_thread(&this->argc, &this->argv, MPI_THREAD_FUNNELED, &provided);
if (provided != MPI_THREAD_FUNNELED) {
Logger->Error() << "Warning MPI did not provide MPI_THREAD_FUNNELED..."<<'\n';
}
this->mCommunication = MPI_COMM_WORLD;
MPI_Comm_rank(this->mCommunication, &this->self);
MPI_Comm_size(this->mCommunication, &this->mProcessCount);
return this->mpGridBox;
}
void StaticServerlessAgent::BeforeMigration() {
this->mPossibleShots = mpEngine->GetValidShots();
}
void StaticServerlessAgent::AfterMigration() {}
void StaticServerlessAgent::BeforeFinalize() {}
MigrationData *StaticServerlessAgent::AfterFinalize(MigrationData *apMigrationData) {
MigrationData *md = apMigrationData;
uint size = md->GetGridSize(X_AXIS) *
md->GetGridSize(Y_AXIS) *
md->GetGridSize(Z_AXIS) *
md->GetGatherDimension();
for (int i = 0; i < md->GetResults().size(); ++i) {
this->mStacks.push_back(new float[size]);
MPI_Reduce(md->GetResultAt(i)->GetData(), this->mStacks[i],
size, MPI_FLOAT, MPI_SUM, 0, this->mCommunication);
}
if (this->self == 0) {
for (int i = 0; i < md->GetResults().size(); ++i) {
md->SetResults(i, new Result(this->mStacks[i]));
}
}
MPI_Finalize();
if (this->self != 0) {
exit(0);
}
return md;
}
bool StaticServerlessAgent::HasNextShot() {
this->mCount++;
return this->mCount < 2;
}
vector<uint> StaticServerlessAgent::GetNextShot() {
vector<uint> process_shots;
uint size = this->mPossibleShots.size();
for (int i = this->self; i < size; i = i + this->mProcessCount) {
process_shots.push_back(this->mPossibleShots[i]);
}
return process_shots;
}
#endif
| 3,202
|
C++
|
.cpp
| 87
| 32.287356
| 86
| 0.690915
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,261
|
StaticServerAgent.cpp
|
brightskiesinc_Reverse_Time_Migration/src/agents/concrete/StaticServerAgent.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(USING_MPI)
#include <mpi.h>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/agents/concrete//StaticServerAgent.hpp>
using namespace std;
using namespace bs::base::logger;
using namespace stbx::agents;
using namespace operations::dataunits;
StaticServerAgent::StaticServerAgent() {
this->mCount = 0;
}
StaticServerAgent::~StaticServerAgent() {
for (auto it : this->mStacks) {
delete[] it;
}
}
GridBox *StaticServerAgent::Initialize() {
LoggerSystem *Logger=LoggerSystem::GetInstance();
this->mpGridBox = mpEngine->Initialize();
int provided;
MPI_Init_thread(&this->argc, &this->argv, MPI_THREAD_FUNNELED, &provided);
if (provided != MPI_THREAD_FUNNELED) {
Logger->Error() << "Warning MPI did not provide MPI_THREAD_FUNNELED..."<<'\n';
}
this->mCommunication = MPI_COMM_WORLD;
MPI_Comm_rank(this->mCommunication, &this->self);
MPI_Comm_size(this->mCommunication, &this->mProcessCount);
return this->mpGridBox;
}
void StaticServerAgent::BeforeMigration() {
this->mPossibleShots = mpEngine->GetValidShots();
}
void StaticServerAgent::AfterMigration() {}
void StaticServerAgent::BeforeFinalize() {}
MigrationData *StaticServerAgent::AfterFinalize(MigrationData *apMigrationData) {
MigrationData *md = apMigrationData;
uint size = md->GetGridSize(X_AXIS) *
md->GetGridSize(Y_AXIS) *
md->GetGridSize(Z_AXIS) *
md->GetGatherDimension();
for (int i = 0; i < md->GetResults().size(); ++i) {
mStacks.push_back(new float[size]);
MPI_Reduce(md->GetResultAt(i)->GetData(), this->mStacks[i],
size, MPI_FLOAT, MPI_SUM, 0, this->mCommunication);
}
if (this->self == 0) {
for (int i = 0; i < md->GetResults().size(); ++i) {
md->SetResults(i, new Result(this->mStacks[i]));
}
}
MPI_Finalize();
if (this->self != 0) {
exit(0);
}
return md;
}
bool StaticServerAgent::HasNextShot() {
this->mCount++;
return this->mCount > 1 ? false : true;
}
vector<uint> StaticServerAgent::GetNextShot() {
vector<uint> process_shots;
if (this->self == 0) {
process_shots.clear();
return process_shots;
}
uint size = mPossibleShots.size();
for (int i = this->self - 1; i < size; i = i + (this->mProcessCount - 1)) {
process_shots.push_back(this->mPossibleShots[i]);
}
return process_shots;
}
#endif
| 3,260
|
C++
|
.cpp
| 91
| 31.21978
| 86
| 0.678946
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,262
|
NormalAgent.cpp
|
brightskiesinc_Reverse_Time_Migration/src/agents/concrete/NormalAgent.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stbx/agents/concrete/NormalAgent.hpp>
using namespace std;
using namespace stbx::agents;
using namespace operations::dataunits;
NormalAgent::~NormalAgent() = default;
GridBox *NormalAgent::Initialize() {
return Agent::Initialize();
}
void NormalAgent::BeforeMigration() {}
void NormalAgent::AfterMigration() {}
void NormalAgent::BeforeFinalize() {}
MigrationData *NormalAgent::AfterFinalize(MigrationData *aMigrationData) {
return aMigrationData;
}
bool NormalAgent::HasNextShot() {
this->mCount++;
return this->mCount < 2;
}
vector<uint> NormalAgent::GetNextShot() {
return this->mpEngine->GetValidShots();
}
| 1,409
|
C++
|
.cpp
| 39
| 33.897436
| 76
| 0.768212
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,263
|
DynamicServerlessAgent.cpp
|
brightskiesinc_Reverse_Time_Migration/src/agents/concrete/DynamicServerlessAgent.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(USING_MPI)
#include <mpi.h>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/agents/concrete/DynamicServerlessAgent.hpp>
using namespace std;
using namespace bs::base::logger;
using namespace stbx::agents;
using namespace operations::dataunits;
DynamicServerlessAgent::~DynamicServerlessAgent() {
for (auto it : this->mStacks) {
delete[] it;
}
}
GridBox *DynamicServerlessAgent::Initialize() {
LoggerSystem *Logger=LoggerSystem::GetInstance();
this->mpGridBox = mpEngine->Initialize();
int provided;
MPI_Init_thread(&this->argc, &this->argv, MPI_THREAD_FUNNELED, &provided);
if (provided != MPI_THREAD_FUNNELED) {
Logger->Error() << "Warning MPI did not provide MPI_THREAD_FUNNELED..." <<'\n';
}
this->mCommunication = MPI_COMM_WORLD;
MPI_Comm_rank(this->mCommunication, &this->self);
MPI_Comm_size(this->mCommunication, &this->mProcessCount);
return this->mpGridBox;
}
void DynamicServerlessAgent::BeforeMigration() {
if (this->self == 0) {
this->mPossibleShots = mpEngine->GetValidShots();
this->mShotsSize = this->mPossibleShots.size();
// The server is assigned the first shot ID to work on.
this->mMasterCurrentShotID = this->mPossibleShots[this->mShotTracker];
/*Incrementing the shot ID tracker.*/
this->mShotTracker++;
// Incrementing the count that indicates the first shots iterator
this->mShotsCount++;
// The server(process with rank 0) allocates the mig_flag to each client process:
// 0 for a process if (process rank < # of shots) -->it will be working on a shot.
// 1 if (process rank >=# of shots) -->there is no enough shots for this process.
for (int i = 1; i < this->mProcessCount; i++) {
// process_rank >= number of shots
if (this->mShotsCount == this->mShotsSize) {
this->flag[4] = 1;
} else {
// process rank < # of shots
this->mShotsCount++;
}
// Server sends a mig_flag to each client process
MPI_Send(&this->flag[4], 1, MPI_INT, i, 20, this->mCommunication);
}
// Server sends one shot ID to each client process that will be working on a shot.
for (int i = 1; i < min<int>(this->mProcessCount, this->mShotsSize); ++i) {
flag[0] = this->mPossibleShots[i];
MPI_Send(&this->flag[0], 1, MPI_INT, i, 2, this->mCommunication);
// Server updates the tracking of the coming shot ID to be processed
this->mShotTracker++;
}
} else {
// Each client process receives the mig_flag form the client
MPI_Recv(&this->flag[4], 1, MPI_INT, 0, 20, mCommunication, &mStatus);
//Getting the valid shots.
vector<uint> temporary_shots;
temporary_shots = mpEngine->GetValidShots();
}
}
void DynamicServerlessAgent::AfterMigration() {
if (this->self == 0) {
while (this->mShotTracker < this->mShotsSize) {
// Server is assigned the coming shot ID to work on
this->mMasterCurrentShotID = this->mPossibleShots[mShotTracker];
// Server updates the tracking of the coming shot ID to be processed
this->mShotTracker++;
if (this->mShotTracker == this->mShotsSize) {
this->mHasShotDynamic = true;
break;
} else {
for (int m = 0; m < this->mProcessCount - 1; ++m) {
/*The server is sending to all client processes a shot_flag of 0 which means there are still shots available*/
MPI_Send(&this->flag[1], 1, MPI_INT, m + 1, 3, this->mCommunication);
/*The server receives the av_flag and rank from the finished client*/
MPI_Recv(&this->flag[2], 2, MPI_INT, m + 1, 14, this->mCommunication, &this->mStatus);
/*If the av_flag equals 1*/
if (this->flag[2] == 1) {
this->flag[0] = this->mPossibleShots[mShotTracker];
int finished = this->flag[3];
// Server sends the coming shot ID to be processed
// to the client who send the av_flag
MPI_Send(&this->flag[0], 1, MPI_INT, finished, 2, this->mCommunication);
/*The server updates the tracking of the coming shot ID to be processed*/
this->mShotTracker++;
/*If there are no shots available*/
if (this->mShotTracker == this->mShotsSize) {
break;
}
}
}
}
return;
}
// As there are no shots available the shot_flag will be 1
this->flag[1] = 1;
// The server sends to all client processes a shot_flag of 1
for (int i = 1; i < min<int>(this->mProcessCount, this->mShotsSize); ++i) {
MPI_Send(&this->flag[1], 1, MPI_INT, i, 3, this->mCommunication);
}
} else {
// Each client process receives the shot_flag from the server.
MPI_Recv(&this->flag[1], 1, MPI_INT, 0, 3, this->mCommunication, &this->mStatus);
if (this->flag[1] == 0) {
// Indicates that it is now available
this->flag[2] = 1;
// Current process rank
this->flag[3] = self;
// The client who finishes, sends av_flag (flag[2])
// to the server to state that it is now available.
// It sends also its rank to the server as an identification.
MPI_Send(&this->flag[2], 2, MPI_INT, 0, 14, this->mCommunication);
}
}
}
void DynamicServerlessAgent::BeforeFinalize() {}
MigrationData *DynamicServerlessAgent::AfterFinalize(MigrationData *apMigrationData) {
MigrationData *md = apMigrationData;
uint size = md->GetGridSize(X_AXIS) *
md->GetGridSize(Y_AXIS) *
md->GetGridSize(Z_AXIS) *
md->GetGatherDimension();
for (int i = 0; i < md->GetResults().size(); ++i) {
mStacks.push_back(new float[size]);
MPI_Reduce(md->GetResultAt(i)->GetData(), this->mStacks[i],
size, MPI_FLOAT, MPI_SUM, 0, this->mCommunication);
}
if (this->self == 0) {
for (int i = 0; i < md->GetResults().size(); ++i) {
md->SetResults(i, new Result(this->mStacks[i]));
}
}
MPI_Finalize();
if (this->self != 0) {
exit(0);
}
return md;
}
bool DynamicServerlessAgent::HasNextShot() {
if (self == 0) {
if (this->mHasShotDynamic && this->flag[1] == 1) {
this->mCount++;
return this->mCount > 1 ? false : true;
} else if (this->flag[1] == 1) {
return false;
} else {
return true;
}
} else {
if (this->flag[4] == 1) {
return false;
} else {
if (this->flag[1] == 0) {
// Each client process receives the shot ID to work on from the server.
MPI_Recv(&this->flag[0], 1, MPI_INT, 0, 2, this->mCommunication, &this->mStatus);
return true;
} else {
return false;
}
}
}
}
vector<uint> DynamicServerlessAgent::GetNextShot() {
if (this->self == 0) {
this->mProcessShots.clear();
this->mProcessShots.push_back(this->mMasterCurrentShotID);
return this->mProcessShots;
} else {
this->mPossibleShots.clear();
this->mPossibleShots.push_back(this->flag[0]);
return this->mPossibleShots;
}
}
#endif
| 8,579
|
C++
|
.cpp
| 197
| 34.010152
| 130
| 0.586446
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,264
|
NormalWriter.cpp
|
brightskiesinc_Reverse_Time_Migration/src/writers/concrete/NormalWriter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stbx/writers/concrete/NormalWriter.hpp>
using namespace std;
using namespace stbx::writers;
using namespace operations::utils::filters;
using namespace operations::utils::io;
void
NormalWriter::SpecifyRawMigration() {
mRawMigration = mpMigrationData->GetResultAt(0)->GetData();
}
void
NormalWriter::PostProcess() {
}
| 1,094
|
C++
|
.cpp
| 30
| 34.6
| 76
| 0.778093
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,265
|
Generator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/Generator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <stbx/generators/Generator.hpp>
#include <stbx/generators/common/Keys.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <stbx/generators/primitive/CallbacksGenerator.hpp>
#include <stbx/generators/concrete/computation-parameters/computation_parameters_generator.h>
#include <stbx/generators/primitive/ComponentsGenerator.hpp>
using namespace std;
using namespace bs::base::exceptions;
using namespace bs::base::logger;
using namespace bs::base::configurations;
using namespace stbx::agents;
using namespace stbx::writers;
using namespace stbx::generators;
using namespace operations::configurations;
using namespace operations::common;
using namespace operations::helpers::callbacks;
using namespace operations::engines;
using namespace operations::components;
Generator::Generator(const nlohmann::json &mMap) {
this->mMap = mMap;
this->mConfigurationsGenerator = new ConfigurationsGenerator(this->mMap);
this->mOrder = this->mConfigurationsGenerator->GetEquationOrder();
this->mSampling = this->mConfigurationsGenerator->GetGridSampling();
this->mApproximation = this->mConfigurationsGenerator->GetApproximation();
}
CallbackCollection *
Generator::GenerateCallbacks(const string &aWritePath) {
auto callbacks_map = this->mMap[K_CALLBACKS];
auto callbacks_generator = new CallbacksGenerator(aWritePath, callbacks_map);
return callbacks_generator->GenerateCallbacks();
}
ModellingEngineConfigurations *
Generator::GenerateModellingEngineConfiguration(const string &aWritePath) {
auto logger = LoggerSystem::GetInstance();
auto configuration = new ModellingEngineConfigurations();
logger->Info() << "Reading model files..." << '\n';
configuration->SetModelFiles(this->mConfigurationsGenerator->GetModelFiles());
logger->Info() << "Reading trace files..." << '\n';
configuration->SetTraceFiles(this->mConfigurationsGenerator->GetTraceFiles());
configuration->SetSortMin(this->mConfigurationsGenerator->GetTracesMin());
configuration->SetSortMax(this->mConfigurationsGenerator->GetTracesMax());
configuration->SetSortKey(this->mConfigurationsGenerator->GetTracesSortKey());
auto g = new ComponentsGenerator(this->mMap[K_COMPONENTS],
this->mOrder,
this->mSampling,
this->mApproximation);
if ((this->mOrder == FIRST) || (this->mOrder == SECOND) && (this->mSampling == UNIFORM)) {
configuration->SetComputationKernel(g->GenerateComputationKernel());
configuration->SetModelHandler(g->GenerateModelHandler());
configuration->SetSourceInjector(g->GenerateSourceInjector());
configuration->SetBoundaryManager(g->GenerateBoundaryManager());
configuration->SetTraceManager(g->GenerateTraceManager());
configuration->SetTraceWriter(g->GenerateTraceWriter());
} else {
logger->Error() << "Unsupported settings" << '\n';
exit(EXIT_FAILURE);
}
return configuration;
}
ComputationParameters *
Generator::GenerateParameters() {
return generate_parameters(this->mMap);
}
RTMEngineConfigurations *
Generator::GenerateRTMConfiguration(const string &aWritePath) {
auto logger = LoggerSystem::GetInstance();
auto configuration = new RTMEngineConfigurations();
logger->Info() << "Reading model files..." << '\n';
configuration->SetModelFiles(this->mConfigurationsGenerator->GetModelFiles());
logger->Info() << "Reading trace files..." << '\n';
configuration->SetTraceFiles(this->mConfigurationsGenerator->GetTraceFiles());
configuration->SetSortMin(this->mConfigurationsGenerator->GetTracesMin());
configuration->SetSortMax(this->mConfigurationsGenerator->GetTracesMax());
configuration->SetSortKey(this->mConfigurationsGenerator->GetTracesSortKey());
auto g = new ComponentsGenerator(this->mMap[K_COMPONENTS],
this->mOrder,
this->mSampling,
this->mApproximation);
if ((this->mOrder == FIRST) || (this->mOrder == SECOND) && (this->mSampling == UNIFORM)) {
configuration->SetComputationKernel(g->GenerateComputationKernel());
configuration->SetModelHandler(g->GenerateModelHandler());
configuration->SetSourceInjector(g->GenerateSourceInjector());
configuration->SetBoundaryManager(g->GenerateBoundaryManager());
configuration->SetForwardCollector(g->GenerateForwardCollector(aWritePath));
configuration->SetMigrationAccommodator(g->GenerateMigrationAccommodator());
configuration->SetTraceManager(g->GenerateTraceManager());
} else {
logger->Error() << "Unsupported settings" << '\n';
exit(EXIT_FAILURE);
}
return configuration;
}
Agent *
Generator::GenerateAgent() {
auto logger = LoggerSystem::GetInstance();
auto agents_map = this->mMap[K_SYSTEM][K_AGENT];
Agent *agent;
if (agents_map[OP_K_TYPE].get<string>() == "normal") {
agent = new NormalAgent();
logger->Info() << "using single Agent" << '\n';
}
#if defined(USING_MPI)
else if (agents_map[OP_K_TYPE].get<string>() == "mpi-static-server") {
logger->Info() << "Using MPI Shot Distribution: "
"\n\tDistribution Type: Static With Server" << '\n';
agent = new StaticServerAgent();
} else if (agents_map[OP_K_TYPE].get<string>() == "mpi-static-serverless") {
logger->Info() << "Using MPI Shot Distribution: "
"\n\tDistribution Type: Static Without Server" << '\n';
agent = new StaticServerlessAgent();
} else if (agents_map[OP_K_TYPE].get<string>() == "mpi-dynamic-server") {
logger->Info() << "Using MPI Shot Distribution: "
"\n\tDistribution Type: Dynamic With Server" << '\n';
agent = new DynamicServerAgent();
} else if (agents_map[OP_K_TYPE].get<string>() == "mpi-dynamic-serverless") {
logger->Info() << "Using MPI Shot Distribution:"
"\n\tDistribution Type: Dynamic Without Server" << '\n';
agent = new DynamicServerlessAgent();
}
#endif
else {
throw UNDEFINED_EXCEPTION();
}
return agent;
}
Writer *
Generator::GenerateWriter() {
auto migration_accommodator_map = this->mMap[K_COMPONENTS][K_MIGRATION_ACCOMMODATOR];
auto writer_map = this->mMap[K_SYSTEM][K_WRITER];
Writer *writer;
// If common image gather type, create specified writer. Otherwise,
// use normal one (i.e. Should make it smarter by supporting stacking
// option inside the writer if we have an output with gathers).
if (!migration_accommodator_map.empty()) {
writer = new NormalWriter();
} else if (!writer_map.empty()) {
writer = new NormalWriter();
} else {
writer = new NormalWriter();
}
return writer;
}
EngineConfigurations *
Generator::GenerateEngineConfiguration(const string &aWritePath) {
auto logger = LoggerSystem::GetInstance();
auto algorithm = this->mMap[K_SYSTEM][K_ALGORITHM][OP_K_TYPE];
EngineConfigurations *engine_configuration;
if (algorithm == "rtm") {
engine_configuration = this->GenerateRTMConfiguration(aWritePath);
} else {
logger->Error() << "Unsupported algorithm..."
<< "Terminating...\n";
exit(EXIT_FAILURE);
}
return engine_configuration;
}
Engine *
Generator::GenerateEngine(const string &aWritePath) {
auto logger = LoggerSystem::GetInstance();
auto algorithm = this->mMap[K_SYSTEM][K_ALGORITHM][OP_K_TYPE];
Engine *engine;
if (algorithm == "rtm") {
engine = new RTMEngine(this->GenerateRTMConfiguration(aWritePath),
this->GenerateParameters(),
this->GenerateCallbacks(aWritePath));
logger->Info() << "RTM engine generated successfully...\n";
} else {
logger->Error() << "Unsupported algorithm..."
<< "Terminating...\n";
exit(EXIT_FAILURE);
}
return engine;
}
ConfigurationMap *
Generator::GenerateTimerConfiguration() {
/// @todo: Check if timer is configured
auto unit = this->mMap[K_SYSTEM][K_TIMER][K_TIMER_PROPERTIES][K_TIME_UNIT];
if (unit == "sec") {
unit = 1;
} else if (unit == "milli") {
unit = 1e-3;
} else if (unit == "micro") {
unit = 1e-6;
} else if (unit == "nano") {
unit = 1e-9;
}
this->mMap[K_SYSTEM][K_TIMER][K_TIMER_PROPERTIES][K_TIME_UNIT] = unit;
return new JSONConfigurationMap(this->mMap[K_SYSTEM][K_TIMER]);
}
| 9,738
|
C++
|
.cpp
| 211
| 39.341232
| 94
| 0.679798
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,266
|
computation_parameters_generator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/concrete/computation-parameters/omp/computation_parameters_generator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <omp.h>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <operations/common/ComputationParameters.hpp>
#include <operations/common/DataTypes.h>
#include <stbx/generators/primitive/ComputationParametersGetter.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
using json = nlohmann::json;
using namespace bs::base::logger;
using namespace stbx::generators;
using namespace operations::common;
void print_parameters(ComputationParameters *parameters) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Used parameters : " << '\n';
Logger->Info() << "\torder of stencil used : " << parameters->GetHalfLength() * 2 << '\n';
Logger->Info() << "\tboundary length used : " << parameters->GetBoundaryLength() << '\n';
Logger->Info() << "\tsource frequency : " << parameters->GetSourceFrequency() << '\n';
Logger->Info() << "\tdt relaxation coefficient : " << parameters->GetRelaxedDT() << '\n';
Logger->Info() << "\t# of threads : " << parameters->GetThreadCount() << '\n';
Logger->Info() << "\tblock factor in x-direction : " << parameters->GetBlockX() << '\n';
Logger->Info() << "\tblock factor in z-direction : " << parameters->GetBlockZ() << '\n';
Logger->Info() << "\tblock factor in y-direction : " << parameters->GetBlockY() << '\n';
if (parameters->IsUsingWindow()) {
Logger->Info() << "\tWindow mode : enabled" << '\n';
if (parameters->GetLeftWindow() == 0 && parameters->GetRightWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN X-axis" << '\n';
} else {
Logger->Info() << "\t\tLeft window : " << parameters->GetLeftWindow() << '\n';
Logger->Info() << "\t\tRight window : " << parameters->GetRightWindow() << '\n';
}
if (parameters->GetFrontWindow() == 0 && parameters->GetBackWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN Y-axis" << '\n';
} else {
Logger->Info() << "\t\tFrontal window : " << parameters->GetFrontWindow() << '\n';
Logger->Info() << "\t\tBackward window : " << parameters->GetBackWindow() << '\n';
}
if (parameters->GetDepthWindow() != 0) {
Logger->Info() << "\t\tDepth window : " << parameters->GetDepthWindow() << '\n';
} else {
Logger->Info() << "\t\tNO WINDOW IN Z-axis" << '\n';
}
} else {
Logger->Info() << "\tWindow mode : disabled (To enable set use-window=yes)..." << '\n';
}
}
operations::common::ComputationParameters *
generate_parameters(json &map) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Parsing OpenMP computation properties..." << '\n';
json computation_parameters_map = map["computation-parameters"];
int boundary_length = -1, block_x = -1, block_z = -1, block_y = -1, order = -1;
int left_win = -1, right_win = -1, front_win = -1, back_win = -1, depth_win = -1, use_window = -1;
int n_threads;
float dt_relax = -1, source_frequency = -1;
HALF_LENGTH half_length = O_8;
#pragma omp parallel
{
n_threads = omp_get_num_threads();
}
auto computation_parameters_getter = new ComputationParametersGetter(computation_parameters_map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
order = so.order;
half_length = so.half_length;
boundary_length = computation_parameters_getter->GetBoundaryLength();
source_frequency = computation_parameters_getter->GetSourceFrequency();
dt_relax = computation_parameters_getter->GetDTRelaxed();
block_x = computation_parameters_getter->GetBlock("x");
block_y = computation_parameters_getter->GetBlock("y");
block_z = computation_parameters_getter->GetBlock("z");
Window w = computation_parameters_getter->GetWindow();
left_win = w.left_win;
right_win = w.right_win;
front_win = w.front_win;
back_win = w.back_win;
depth_win = w.depth_win;
use_window = w.use_window;
if (order == -1) {
Logger->Error() << "No valid value provided for key 'stencil-order'..." << '\n';
Logger->Info() << "Using default stencil order of 8" << '\n';
half_length = O_8;
}
if (boundary_length == -1) {
Logger->Error() << "No valid value provided for key 'boundary-length'..." << '\n';
Logger->Info() << "Using default boundary-length of 20" << '\n';
boundary_length = 20;
}
if (source_frequency == -1) {
Logger->Error() << "No valid value provided for key 'source-frequency'..." << '\n';
Logger->Info() << "Using default source frequency of 20" << '\n';
source_frequency = 20;
}
if (dt_relax == -1) {
Logger->Error() << "No valid value provided for key 'dt-relax'..." << '\n';
Logger->Info() << "Using default relaxation coefficient for dt calculation of 0.4" << '\n';
dt_relax = 0.4;
}
if (block_x == -1) {
Logger->Error() << "No valid value provided for key 'block-x'..." << '\n';
Logger->Info() << "Using default blocking factor in x-direction of 560" << '\n';
block_x = 560;
}
if (block_z == -1) {
Logger->Error() << "No valid value provided for key 'block-z'..." << '\n';
Logger->Info() << "Using default blocking factor in z-direction of 35" << '\n';
block_z = 35;
}
if (use_window == -1) {
Logger->Error() << "No valid value provided for key 'use-window'..." << '\n';
Logger->Info() << "Disabling window by default.." << '\n';
use_window = 0;
}
if (use_window) {
if (left_win == -1) {
Logger->Error() << "No valid value provided for key 'left-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
left_win = 0;
}
if (right_win == -1) {
Logger->Error() << "No valid value provided for key 'right-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
right_win = 0;
}
if (depth_win == -1) {
Logger->Error() << "No valid value provided for key 'depth-window'..." << '\n';
Logger->Info() << "Using default window size of 0 - notice if window is 0, no windowing happens" << '\n';
depth_win = 0;
}
if (front_win == -1) {
Logger->Error() << "No valid value provided for key 'front-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
front_win = 0;
}
if (back_win == -1) {
Logger->Error() << "No valid value provided for key 'back-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
back_win = 0;
}
}
auto *parameters = new ComputationParameters(half_length);
auto *configurationsGenerator = new ConfigurationsGenerator(map);
/// General
parameters->SetBoundaryLength(boundary_length);
parameters->SetRelaxedDT(dt_relax);
parameters->SetSourceFrequency(source_frequency);
parameters->SetIsUsingWindow(use_window == 1);
parameters->SetLeftWindow(left_win);
parameters->SetRightWindow(right_win);
parameters->SetDepthWindow(depth_win);
parameters->SetFrontWindow(front_win);
parameters->SetBackWindow(back_win);
parameters->SetEquationOrder(configurationsGenerator->GetEquationOrder());
parameters->SetApproximation(configurationsGenerator->GetApproximation());
parameters->SetPhysics(configurationsGenerator->GetPhysics());
/// OMP
parameters->SetThreadCount(n_threads);
parameters->SetBlockX(block_x);
parameters->SetBlockZ(block_z);
parameters->SetBlockY(block_y);
print_parameters(parameters);
return parameters;
}
| 9,135
|
C++
|
.cpp
| 188
| 41.595745
| 130
| 0.614515
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,267
|
computation_parameters_generator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/concrete/computation-parameters/omp-offload/computation_parameters_generator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <omp.h>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/generators/primitive/ComputationParametersGetter.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <operations/common/ComputationParameters.hpp>
#include <operations/common/DataTypes.h>
using json = nlohmann::json;
using namespace bs::base::logger;
using namespace stbx::generators;
using namespace operations::common;
void print_parameters(ComputationParameters *parameters) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Used parameters : " << '\n';
Logger->Info() << "\torder of stencil used : " << parameters->GetHalfLength() * 2 << '\n';
Logger->Info() << "\tboundary length used : " << parameters->GetBoundaryLength() << '\n';
Logger->Info() << "\tsource frequency : " << parameters->GetSourceFrequency() << '\n';
Logger->Info() << "\tdt relaxation coefficient : " << parameters->GetRelaxedDT() << '\n';
Logger->Info() << "\t# of threads : " << parameters->GetThreadCount() << '\n';
Logger->Info() << "\tblock factor in x-direction : " << parameters->GetBlockX() << '\n';
Logger->Info() << "\tblock factor in z-direction : " << parameters->GetBlockZ() << '\n';
Logger->Info() << "\tblock factor in y-direction : " << parameters->GetBlockY() << '\n';
if (parameters->IsUsingWindow()) {
Logger->Info() << "\tWindow mode : enabled" << '\n';
if (parameters->GetLeftWindow() == 0 && parameters->GetRightWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN X-axis" << '\n';
} else {
Logger->Info() << "\t\tLeft window : " << parameters->GetLeftWindow() << '\n';
Logger->Info() << "\t\tRight window : " << parameters->GetRightWindow() << '\n';
}
if (parameters->GetFrontWindow() == 0 && parameters->GetBackWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN Y-axis" << '\n';
} else {
Logger->Info() << "\t\tFrontal window : " << parameters->GetFrontWindow() << '\n';
Logger->Info() << "\t\tBackward window : " << parameters->GetBackWindow() << '\n';
}
if (parameters->GetDepthWindow() != 0) {
Logger->Info() << "\t\tDepth window : " << parameters->GetDepthWindow() << '\n';
} else {
Logger->Info() << "\t\tNO WINDOW IN Z-axis" << '\n';
}
} else {
Logger->Info() << "\tWindow mode : disabled (To enable set use-window=yes)..." << '\n';
}
}
operations::common::ComputationParameters *
generate_parameters(json &map) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Parsing OpenMP Offload computation properties..." << '\n';
json computation_parameters_map = map["computation-parameters"];
int boundary_length = -1, block_x = -1, block_z = -1, block_y = -1, order = -1;
int left_win = -1, right_win = -1, front_win = -1, back_win = -1, depth_win = -1, use_window = -1;
float dt_relax = -1, source_frequency = -1;
HALF_LENGTH half_length = O_8;
auto computation_parameters_getter = new ComputationParametersGetter(computation_parameters_map);
StencilOrder so = computation_parameters_getter->GetStencilOrder();
order = so.order;
half_length = so.half_length;
boundary_length = computation_parameters_getter->GetBoundaryLength();
source_frequency = computation_parameters_getter->GetSourceFrequency();
dt_relax = computation_parameters_getter->GetDTRelaxed();
block_x = computation_parameters_getter->GetBlock("x");
block_y = computation_parameters_getter->GetBlock("y");
block_z = computation_parameters_getter->GetBlock("z");
Window w = computation_parameters_getter->GetWindow();
left_win = w.left_win;
right_win = w.right_win;
front_win = w.front_win;
back_win = w.back_win;
depth_win = w.depth_win;
use_window = w.use_window;
if (order == -1) {
Logger->Error() << "No valid value provided for key 'stencil-order'..." << '\n';
Logger->Info() << "Using default stencil order of 8" << '\n';
half_length = O_8;
}
if (boundary_length == -1) {
Logger->Error() << "No valid value provided for key 'boundary-length'..." << '\n';
Logger->Info() << "Using default boundary-length of 20" << '\n';
boundary_length = 20;
}
if (source_frequency == -1) {
Logger->Error() << "No valid value provided for key 'source-frequency'..." << '\n';
Logger->Info() << "Using default source frequency of 20" << '\n';
source_frequency = 20;
}
if (dt_relax == -1) {
Logger->Error() << "No valid value provided for key 'dt-relax'..." << '\n';
Logger->Info() << "Using default relaxation coefficient for dt calculation of 0.4" << '\n';
dt_relax = 0.4;
}
if (block_x == -1) {
Logger->Error() << "No valid value provided for key 'block-x'..." << '\n';
Logger->Info() << "Using default blocking factor in x-direction of 560" << '\n';
block_x = 560;
}
if (block_z == -1) {
Logger->Error() << "No valid value provided for key 'block-z'..." << '\n';
Logger->Info() << "Using default blocking factor in z-direction of 35" << '\n';
block_z = 35;
}
if (use_window == -1) {
Logger->Error() << "No valid value provided for key 'use-window'..." << '\n';
Logger->Info() << "Disabling window by default.." << '\n';
use_window = 0;
}
if (use_window) {
if (left_win == -1) {
Logger->Error() << "No valid value provided for key 'left-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
left_win = 0;
}
if (right_win == -1) {
Logger->Error() << "No valid value provided for key 'right-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
right_win = 0;
}
if (depth_win == -1) {
Logger->Error() << "No valid value provided for key 'depth-window'..." << '\n';
Logger->Info() << "Using default window size of 0 - notice if window is 0, no windowing happens" << '\n';
depth_win = 0;
}
if (front_win == -1) {
Logger->Error() << "No valid value provided for key 'front-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
front_win = 0;
}
if (back_win == -1) {
Logger->Error() << "No valid value provided for key 'back-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
back_win = 0;
}
}
auto *parameters = new ComputationParameters(half_length);
auto *configurationsGenerator = new ConfigurationsGenerator(map);
/// General
parameters->SetBoundaryLength(boundary_length);
parameters->SetRelaxedDT(dt_relax);
parameters->SetSourceFrequency(source_frequency);
parameters->SetIsUsingWindow(use_window == 1);
parameters->SetLeftWindow(left_win);
parameters->SetRightWindow(right_win);
parameters->SetDepthWindow(depth_win);
parameters->SetFrontWindow(front_win);
parameters->SetBackWindow(back_win);
parameters->SetEquationOrder(configurationsGenerator->GetEquationOrder());
parameters->SetApproximation(configurationsGenerator->GetApproximation());
parameters->SetPhysics(configurationsGenerator->GetPhysics());
/// OMP
// parameters->SetThreadCount(n_threads);
parameters->SetBlockX(block_x);
parameters->SetBlockZ(block_z);
parameters->SetBlockY(block_y);
print_parameters(parameters);
return parameters;
}
| 9,051
|
C++
|
.cpp
| 183
| 42.415301
| 130
| 0.614846
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,268
|
computation_parameters_generator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/concrete/computation-parameters/oneapi/computation_parameters_generator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <CL/sycl.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <bs/base/backend/Backend.hpp>
#include <stbx/generators/primitive/ComputationParametersGetter.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <operations/common/ComputationParameters.hpp>
#include <operations/common/DataTypes.h>
using namespace std;
using json = nlohmann::json;
using namespace bs::base::backend;
using namespace bs::base::logger;
using namespace operations::common;
using namespace stbx::generators;
// This is the class provided to SYCL runtime by the application to decide
// on which Device to run, or whether to run at all.
// When selecting a Device, SYCL runtime first takes (1) a selector provided by
// the program or a default one and (2) the set of all available devices. Then
// it passes each Device to the '()' operator of the selector. Device, for
// which '()' returned the highest number, is selected. If a negative number
// was returned for all devices, then the selection process will cause an
// exception.
class MyDeviceSelector : public cl::sycl::device_selector {
public:
MyDeviceSelector(const std::string &p) : pattern(p) {
// std::cout << "Looking for \"" << p << "\" devices" << std::endl;
}
// This is the function which gives a "rating" to devices.
virtual int operator()(const cl::sycl::device &device) const override {
// The template parameter to Device.get_info can be a variety of properties
// defined by the SYCL spec's cl::sycl::info:: enum. Properties may have
// different types. Here we query name which is a string.
const std::string name = device.get_info<cl::sycl::info::device::name>();
// std::cout << "Trying Device: " << name << "..." << std::endl;
// std::cout << " Vendor: " <<
// Device.get_info<cl::sycl::info::device::vendor>() << std::endl;
// Device with pattern in the name is prioritized:
return (name.find(pattern) != std::string::npos) ? 100 : 1;
}
private:
std::string pattern;
};
/*
* Host-Code
* Utility function to check blocking factor.
*/
void CheckBlockingFactors(cl::sycl::queue *q,
ComputationParameters *parameters) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
auto device = q->get_device();
int temp_block_x = parameters->GetBlockX();
if (temp_block_x % 16 != 0 && temp_block_x != 1) {
temp_block_x = (temp_block_x + (16 - (temp_block_x % 16)));
}
int temp_block_z = parameters->GetBlockZ();
auto maxBlockSize =
device.get_info<cl::sycl::info::device::max_work_group_size>();
if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::CPU) {
// No need to check since the blocks don't control the group launching.
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU_SHARED) {
// Reject if STATIC block is bigger than max block size.
if (temp_block_x * temp_block_z > maxBlockSize) {
Logger->Info() << "Warning : Invalid block size." << '\n';
Logger->Info() << "Max workgroup size : " << maxBlockSize << '\n';
Logger->Info() << "Used workgroup size : block-x(" << temp_block_x << ") * block-z("
<< temp_block_z << ") = " << temp_block_x * temp_block_z << '\n';
Logger->Info() << "Notice : if block-x entered by user is different than the one "
"entered,"
<< " this is because if block-x is not equal 1 and is not divisible "
"by 16. It is increased to be divisible by 16"
<< '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
if (temp_block_z < parameters->GetHalfLength()) {
Logger->Info() << "Warning : Small block-z for the order selected" << '\n';
Logger->Info()
<< "For the selected order : a block-z of at least the half length = "
<< parameters->GetHalfLength() << " must be selected" << '\n';
Logger->Info() << "Block in z = " << temp_block_z << '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
if (temp_block_x < parameters->GetHalfLength()) {
Logger->Info() << "Warning : Small block-x for the order selected" << '\n';
Logger->Info()
<< "For the selected order : a block-x of at least the half length = "
<< parameters->GetHalfLength() << " must be selected" << '\n';
Logger->Info() << "Block in x = " << temp_block_x << '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU_SEMI_SHARED) {
// Reject if block-x is bigger than max block size.
if (temp_block_x > maxBlockSize) {
Logger->Info() << "Warning : Invalid block size." << '\n';
Logger->Info() << "Max workgroup size : " << maxBlockSize << '\n';
Logger->Info() << "Used workgroup size : block-x = " << temp_block_x << '\n';
Logger->Info() << "Notice : if block-x entered by user is different than the one "
"entered,"
<< " this is because if block-x is not equal 1 and is not divisible "
"by 16. It is increased to be divisible by 16"
<< '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
if (temp_block_x < parameters->GetHalfLength()) {
Logger->Info() << "Warning : Small block-x for the order selected" << '\n';
Logger->Info()
<< "For the selected order : a block-x of at least the half length = "
<< parameters->GetHalfLength() << " must be selected" << '\n';
Logger->Info() << "Block in x = " << temp_block_x << '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU) {
// Reject if block-x is bigger than max block size.
if (temp_block_x > maxBlockSize) {
Logger->Info() << "Warning : Invalid block size." << '\n';
Logger->Info() << "Max workgroup size : " << maxBlockSize << '\n';
Logger->Info() << "Used workgroup size : block-x = " << temp_block_x << '\n';
Logger->Info() << "Notice : if block-x entered by user is different than the one "
"entered,"
<< " this is because if block-x is not equal 1 and is not divisible "
"by 16. It is increased to be divisible by 16"
<< '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
if (temp_block_x < parameters->GetHalfLength()) {
Logger->Info() << "Warning : Small block-x for the order selected" << '\n';
Logger->Info()
<< "For the selected order : a block-x of at least the half length = "
<< parameters->GetHalfLength() << " must be selected" << '\n';
Logger->Info() << "Block in x = " << temp_block_x << '\n';
Logger->Info() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
}
}
/*
* Host-Code
* Utility function to print Device info
*/
void PrintTargetInfo(cl::sycl::queue *q) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
auto device = q->get_device();
auto maxBlockSize =
device.get_info<cl::sycl::info::device::max_work_group_size>();
auto maxEUCount =
device.get_info<cl::sycl::info::device::max_compute_units>();
Logger->Info() << " Running on " << device.get_info<cl::sycl::info::device::name>() << '\n';
Logger->Info() << " The Device Max Work Group Size is : " << maxBlockSize << '\n';
Logger->Info() << " The Device Max EUCount is : " << maxEUCount << '\n';
}
void print_parameters(ComputationParameters *parameters) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Used parameters : " << '\n';
Logger->Info() << "\torder of stencil used : " << parameters->GetHalfLength() * 2 << '\n';
Logger->Info() << "\tboundary length used : " << parameters->GetBoundaryLength() << '\n';
Logger->Info() << "\tsource frequency : " << parameters->GetSourceFrequency() << '\n';
Logger->Info() << "\tdt relaxation coefficient : " << parameters->GetRelaxedDT() << '\n';
Logger->Info() << "\tblock factor in x-direction : " << parameters->GetBlockX() << '\n';
Logger->Info() << "\tblock factor in z-direction : " << parameters->GetBlockZ() << '\n';
Logger->Info() << "\tblock factor in y-direction : " << parameters->GetBlockY() << '\n';
if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::CPU) {
Logger->Info() << "\tUsing CPU Algorithm" << '\n';
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU_SHARED) {
Logger->Info() << "\tUsing GPU Algorithm - Shared Memory Algorithm" << '\n';
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU_SEMI_SHARED) {
Logger->Info() << "\tUsing GPU Algorithm - Sliding in Z - Shared Memory X Algorithm" << '\n';
} else if (Backend::GetInstance()->GetAlgorithm() == SYCL_ALGORITHM::GPU) {
Logger->Info() << "\tUsing GPU Algorithm - Slice z + Shared x Hybrid" << '\n';
}
if (parameters->IsUsingWindow()) {
Logger->Info() << "\tWindow mode : enabled" << '\n';
if (parameters->GetLeftWindow() == 0 && parameters->GetRightWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN X-axis" << '\n';
} else {
Logger->Info() << "\t\tLeft window : " << parameters->GetLeftWindow() << '\n';
Logger->Info() << "\t\tRight window : " << parameters->GetRightWindow() << '\n';
}
if (parameters->GetFrontWindow() == 0 && parameters->GetBackWindow() == 0) {
Logger->Info() << "\t\tNO WINDOW IN Y-axis" << '\n';
} else {
Logger->Info() << "\t\tFrontal window : " << parameters->GetFrontWindow() << '\n';
Logger->Info() << "\t\tBackward window : " << parameters->GetBackWindow() << '\n';
}
if (parameters->GetDepthWindow() != 0) {
Logger->Info() << "\t\tDepth window : " << parameters->GetDepthWindow() << '\n';
} else {
Logger->Info() << "\t\tNO WINDOW IN Z-axis" << '\n';
}
} else {
Logger->Info() << "\tWindow mode : disabled (To enable set use-window=yes)..." << '\n';
}
}
struct Algorithm {
int device_selected = DEF_VAL;
SYCL_ALGORITHM selected_device = SYCL_ALGORITHM::CPU;
};
Algorithm ParseAlgorithm(json &map) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
string value = map["algorithm"].get<std::string>();
Algorithm alg;
if (value == "cpu") {
alg.device_selected = 1;
alg.selected_device = SYCL_ALGORITHM::CPU;
} else if (value == "gpu-shared") {
alg.device_selected = 1;
alg.selected_device = SYCL_ALGORITHM::GPU_SHARED;
} else if (value == "gpu-semi-shared") {
alg.device_selected = 1;
alg.selected_device = SYCL_ALGORITHM::GPU_SEMI_SHARED;
} else if (value == "gpu") {
alg.device_selected = 1;
alg.selected_device = SYCL_ALGORITHM::GPU;
} else {
Logger->Error() << "Invalid value entered for algorithm : must be <cpu> , <gpu> , "
"<gpu-shared> or <gpu-semi-shared>" << '\n';
}
return alg;
}
struct Device {
int device_name = DEF_VAL;
string device_pattern;
};
Device ParseDevice(json &map) {
string value = map["device"].get<std::string>();
Device d;
if (value != "none") {
d.device_name = 1;
d.device_pattern = value;
}
return d;
}
/*!
* File format should be follow the following example :
*
* stencil-order=8
* boundary-length=20
* source-frequency=200
* dt-relax=0.4
* thread-number=4
* block-x=500
* block-z=44
* block-y=5
* Device=cpu
*/
ComputationParameters *generate_parameters(json &map) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Parsing DPC++ computation properties..." << '\n';
json computation_parameters_map = map["computation-parameters"];
int boundary_length = -1, block_x = -1, block_z = -1, block_y = -1,
order = -1;
float dt_relax = -1, source_frequency = -1;
uint cor_block = -1;
HALF_LENGTH half_length = O_8;
string device_pattern;
int device_selected = -1;
int left_win = -1, right_win = -1, front_win = -1, back_win = -1, depth_win = -1, use_window = -1, device_name = -1;
SYCL_ALGORITHM selected_device = SYCL_ALGORITHM::CPU;
auto *computationParametersGetter = new stbx::generators::ComputationParametersGetter(computation_parameters_map);
StencilOrder so = computationParametersGetter->GetStencilOrder();
order = so.order;
half_length = so.half_length;
boundary_length = computationParametersGetter->GetBoundaryLength();
source_frequency = computationParametersGetter->GetSourceFrequency();
dt_relax = computationParametersGetter->GetDTRelaxed();
block_x = computationParametersGetter->GetBlock("x");
block_y = computationParametersGetter->GetBlock("y");
block_z = computationParametersGetter->GetBlock("z");
Window w = computationParametersGetter->GetWindow();
left_win = w.left_win;
right_win = w.right_win;
front_win = w.front_win;
back_win = w.back_win;
depth_win = w.depth_win;
use_window = w.use_window;
Algorithm alg = ParseAlgorithm(computation_parameters_map);
device_selected = alg.device_selected;
selected_device = alg.selected_device;
Device d = ParseDevice(computation_parameters_map);
device_name = d.device_name;
device_pattern = d.device_pattern;
if (order == -1) {
Logger->Error() << "No valid value provided for key 'stencil-order'..." << '\n';
Logger->Info() << "Using default stencil order of 8" << '\n';
half_length = O_8;
}
if (boundary_length == -1) {
Logger->Error() << "No valid value provided for key 'boundary-length'..." << '\n';
Logger->Info() << "Using default boundary-length of 20" << '\n';
boundary_length = 20;
}
if (source_frequency == -1) {
Logger->Error() << "No valid value provided for key 'source-frequency'..." << '\n';
Logger->Info() << "Using default source frequency of 20" << '\n';
source_frequency = 20;
}
if (dt_relax == -1) {
Logger->Error() << "No valid value provided for key 'dt-relax'..." << '\n';
Logger->Info() << "Using default relaxation coefficient for dt calculation of 0.4" << '\n';
dt_relax = 0.4;
}
if (block_x == -1) {
Logger->Error() << "No valid value provided for key 'block-x'..." << '\n';
Logger->Info() << "Using default blocking factor in x-direction of 560" << '\n';
block_x = 560;
}
if (block_z == -1) {
Logger->Error() << "No valid value provided for key 'block-z'..." << '\n';
Logger->Info() << "Using default blocking factor in z-direction of 35" << '\n';
block_z = 35;
}
if (block_y == -1) {
Logger->Error() << "No valid value provided for key 'block-y'..." << '\n';
Logger->Info() << "Using default blocking factor in y-direction of 5" << '\n';
block_y = 5;
}
if (device_selected == -1) {
Logger->Error() << "No valid value provided for key 'Device'..." << '\n';
Logger->Info() << "Using default Device : CPU" << '\n';
selected_device = SYCL_ALGORITHM::CPU;
}
if (use_window == -1) {
Logger->Error() << "No valid value provided for key 'use-window'..." << '\n';
Logger->Info() << "Disabling window by default.." << '\n';
use_window = 0;
}
if (use_window) {
if (left_win == -1) {
Logger->Error() << "No valid value provided for key 'left-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
left_win = 0;
}
if (right_win == -1) {
Logger->Error() << "No valid value provided for key 'right-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
right_win = 0;
}
if (depth_win == -1) {
Logger->Error() << "No valid value provided for key 'depth-window'..." << '\n';
Logger->Info() << "Using default window size of 0 - notice if window is 0, no windowing happens" << '\n';
depth_win = 0;
}
if (front_win == -1) {
Logger->Error() << "No valid value provided for key 'front-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
front_win = 0;
}
if (back_win == -1) {
Logger->Error() << "No valid value provided for key 'back-window'..." << '\n';
Logger->Info()
<< "Using default window size of 0- notice if both window in an axis are 0, no windowing happens on that axis"
<< '\n';
back_win = 0;
}
}
auto *parameters = new ComputationParameters(half_length);
auto *configurationsGenerator = new ConfigurationsGenerator(map);
/// General
parameters->SetBoundaryLength(boundary_length);
parameters->SetRelaxedDT(dt_relax);
parameters->SetSourceFrequency(source_frequency);
parameters->SetIsUsingWindow(use_window == 1);
parameters->SetLeftWindow(left_win);
parameters->SetRightWindow(right_win);
parameters->SetDepthWindow(depth_win);
parameters->SetFrontWindow(front_win);
parameters->SetBackWindow(back_win);
parameters->SetEquationOrder(configurationsGenerator->GetEquationOrder());
parameters->SetApproximation(configurationsGenerator->GetApproximation());
parameters->SetPhysics(configurationsGenerator->GetPhysics());
/// OneAPI
parameters->SetBlockX(block_x);
parameters->SetBlockZ(block_z);
parameters->SetBlockY(block_y);
auto asyncHandler = [&](cl::sycl::exception_list eL) {
for (auto &e : eL) {
try {
std::rethrow_exception(e);
} catch (cl::sycl::exception &e) {
Logger->Error() << e.what() << '\n';
Logger->Error() << "fail" << '\n';
// std::terminate() will exit the process, return non-zero, and output a
// message to the user about the exception
std::terminate();
}
}
};
if (device_name != 1) {
if (selected_device == SYCL_ALGORITHM::CPU) {
Logger->Info() << "Using default CPU selector" << '\n';
sycl::cpu_selector cpu_sel;
Backend::GetInstance()->SetDeviceQueue(
new sycl::queue(cpu_sel, asyncHandler));
} else {
Logger->Info() << "Using default GPU selector" << '\n';
sycl::gpu_selector gpu_sel;
Backend::GetInstance()->SetDeviceQueue(
new sycl::queue(gpu_sel, asyncHandler));
}
} else {
Logger->Info() << "Trying to select the Device that is closest to the given pattern '" << device_pattern << "'"
<< '\n';
MyDeviceSelector dev_sel(device_pattern);
Backend::GetInstance()->SetDeviceQueue(
new sycl::queue(dev_sel, asyncHandler));
}
Backend::GetInstance()->SetAlgorithm(selected_device);
print_parameters(parameters);
PrintTargetInfo(Backend::GetInstance()->GetDeviceQueue());
CheckBlockingFactors(Backend::GetInstance()->GetDeviceQueue(), parameters);
return parameters;
}
| 21,426
|
C++
|
.cpp
| 441
| 40.21542
| 130
| 0.585318
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,269
|
ConfigurationsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/primitive/ConfigurationsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <stbx/generators/common/Keys.hpp>
#include <operations/common/DataTypes.h>
using namespace bs::base::logger;
using namespace stbx::generators;
ConfigurationsGenerator::ConfigurationsGenerator(nlohmann::json &aMap) {
this->mMap = aMap;
}
PHYSICS
ConfigurationsGenerator::GetPhysics() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json wave = this->mMap[K_WAVE];
PHYSICS physics = ACOUSTIC;
if (wave[K_PHYSICS].get<std::string>() == "acoustic") {
physics = ACOUSTIC;
Logger->Info() << "Using Acoustic for physics" << '\n';
} else {
Logger->Error() << "Invalid value for physics key : supported values [ acoustic ]" << '\n';
Logger->Info() << "Using Acoustic for physics" << '\n';
}
return physics;
}
EQUATION_ORDER
ConfigurationsGenerator::GetEquationOrder() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json wave = this->mMap[K_WAVE];
EQUATION_ORDER order = SECOND;
if (wave[K_EQUATION_ORDER].get<std::string>() == "second") {
order = SECOND;
Logger->Info() << "Using second order wave equation" << '\n';
} else if (wave[K_EQUATION_ORDER].get<std::string>() == "first") {
order = FIRST;
Logger->Info() << "Using first order wave equation" << '\n';
} else {
Logger->Error() << "Invalid value for equation-order key : supported values [ second | first ]" << '\n';
Logger->Info() << "Using second order wave equation" << '\n';
}
return order;
}
GRID_SAMPLING
ConfigurationsGenerator::GetGridSampling() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json wave = this->mMap[K_WAVE];
GRID_SAMPLING sampling = UNIFORM;
if (wave[K_GRID_SAMPLING].get<std::string>() == "uniform") {
sampling = UNIFORM;
Logger->Info() << "Using uniform grid sampling" << '\n';
} else {
Logger->Error() << "Invalid value for grid-sampling key : supported values [ uniform ]" << '\n';
Logger->Info() << "Using uniform grid sampling" << '\n';
}
return sampling;
}
APPROXIMATION
ConfigurationsGenerator::GetApproximation() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json wave = this->mMap[K_WAVE];
APPROXIMATION approximation = ISOTROPIC;
if (wave[K_APPROXIMATION].get<std::string>() == "isotropic") {
approximation = ISOTROPIC;
Logger->Info() << "Using Isotropic as approximation" << '\n';
} else {
Logger->Error() << "Invalid value for approximation key : supported values [ isotropic ]" << '\n';
Logger->Info() << "Using Acoustic for Isotropic" << '\n';
}
return approximation;
}
std::map<std::string, std::string>
ConfigurationsGenerator::GetModelFiles() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
std::map<std::string, std::string> model_files;
if (this->mMap[K_MODELS].empty()) {
Logger->Error() << "No entry for models key : a value providing the filename"
" to the file that contains the directories of model files(each in "
"a line) must be provided" << '\n';
Logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
nlohmann::json models = this->mMap[K_MODELS];
if (!models[K_VELOCITY].is_null()) {
model_files[K_VELOCITY] = models[K_VELOCITY].get<std::string>();
}
if (!models[K_DENSITY].is_null()) {
model_files[K_DENSITY] = models[K_DENSITY].get<std::string>();
}
if (!models[K_DELTA].is_null()) {
model_files[K_DELTA] = models[K_DELTA].get<std::string>();
}
if (!models[K_EPSILON].is_null()) {
model_files[K_EPSILON] = models[K_EPSILON].get<std::string>();
}
if (!models[K_THETA].is_null()) {
model_files[K_THETA] = models[K_THETA].get<std::string>();
}
if (!models[K_PHI].is_null()) {
model_files[K_PHI] = models[K_PHI].get<std::string>();
}
Logger->Info() << "The following model files were detected : " << '\n';
int index = 0;
for (auto &model_file : model_files) {
Logger->Info() << "\t" << ++index << ". " << model_file.first << "\t: " << model_file.second << '\n';
}
return model_files;
}
std::vector<std::string>
ConfigurationsGenerator::GetTraceFiles() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json traces = this->mMap[K_TRACES];
std::vector<std::string> traces_files;
if (traces.empty()) {
Logger->Error() << "No entry for traces key : it is necessary to provide it, holding"
"the following keys : paths(list of file paths containing the data),"
" min(number, optional) , max(number, optional),"
" sort-type(string, optional)." << '\n';
Logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
} else {
Logger->Info() << "The following trace files were detected : " << '\n';
for (int i = 0; i < traces[K_PATHS].size(); i++) {
std::string path = traces[K_PATHS][i].get<std::string>();
Logger->Info() << "\t" << (i + 1) << ". " << path << '\n';
traces_files.push_back(path);
}
}
return traces_files;
}
uint ConfigurationsGenerator::GetTracesMin() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json traces = this->mMap[K_TRACES];
Logger->Info() << "Parsing minimum shot id..." << '\n';
uint minimum_key;
if (traces.empty()) {
Logger->Error() << "No entry for traces key : it is necessary to provide it, holding"
"the following keys : paths(list of file paths containing the data),"
" min(number, optional) , max(number, optional),"
" sort-type(string, optional)." << '\n';
Logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
} else {
if (traces[K_MIN].is_null()) {
minimum_key = 0;
} else {
try {
minimum_key = traces[K_MIN].get<uint>();
}
catch (std::invalid_argument &e) {
minimum_key = 0;
Logger->Error() << "Couldn't parse the minimum shot ID to process... Setting to 0" << '\n';
}
}
}
Logger->Info() << "Minimum allowable ID : " << minimum_key << '\n';
return minimum_key;
}
uint ConfigurationsGenerator::GetTracesMax() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json traces = this->mMap[K_TRACES];
Logger->Info() << "Parsing maximum shot id..." << '\n';
uint maximum_key;
if (traces.empty()) {
Logger->Error() << "No entry for traces key : it is necessary to provide it, holding"
"the following keys : paths(list of file paths containing the data),"
" min(number, optional) , max(number, optional),"
" sort-type(string, optional)." << '\n';
Logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
} else {
if (traces[K_MAX].is_null()) {
maximum_key = std::numeric_limits<uint>::max();
} else {
try {
maximum_key = traces[K_MAX].get<uint>();
}
catch (std::invalid_argument &e) {
maximum_key = std::numeric_limits<uint>::max();
Logger->Error() << "Couldn't parse the maximum shot ID to process... Setting to "
<< std::numeric_limits<uint>::max() << '\n';
}
}
}
Logger->Info() << "Maximum allowable ID : " << maximum_key << '\n';
return maximum_key;
}
std::string ConfigurationsGenerator::GetTracesSortKey() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
nlohmann::json traces = this->mMap[K_TRACES];
Logger->Info() << "Parsing sort type..." << '\n';
std::string sort_key = "CSR";
if (traces.empty()) {
Logger->Error() << "No entry for traces key : it is necessary to provide it, holding"
"the following keys : paths(list of file paths containing the data),"
" min(number, optional) , max(number, optional),"
" sort-type(string, optional)." << '\n';
Logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
} else {
if (traces[K_SORT_TYPE].is_null()) {
Logger->Error() << "Couldn't parse sort type... Setting to CSR" << '\n';
} else {
sort_key = traces[K_SORT_TYPE].get<std::string>();
}
}
return sort_key;
}
| 9,686
|
C++
|
.cpp
| 225
| 35.484444
| 112
| 0.591973
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,270
|
ComponentsGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/primitive/ComponentsGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stbx/generators/primitive/ComponentsGenerator.hpp>
#include <stbx/generators/common/Keys.hpp>
#include <operations/configurations/MapKeys.h>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
using namespace std;
using namespace stbx::generators;
using namespace bs::base::configurations;
using namespace operations::common;
using namespace operations::components;
using namespace bs::base::exceptions;
using namespace bs::base::logger;
ComponentsGenerator::ComponentsGenerator(const nlohmann::json &aMap,
EQUATION_ORDER aOrder,
GRID_SAMPLING aSampling,
APPROXIMATION aApproximation) {
this->mMap = aMap;
this->mOrder = aOrder;
this->mSampling = aSampling;
this->mApproximation = aApproximation;
}
ComputationKernel *
ComponentsGenerator::GenerateComputationKernel() {
auto logger = LoggerSystem::GetInstance();
auto map = this->TruncateMap(K_COMPUTATION_KERNEL);
if (this->mOrder == FIRST && this->mSampling == UNIFORM) {
switch (this->mApproximation) {
case ISOTROPIC:
logger->Info() << "Generating Staggered First Order Isotropic Computation Kernel...\n";
return new StaggeredComputationKernel(map);
}
} else if (this->mOrder == SECOND && this->mSampling == UNIFORM) {
switch (this->mApproximation) {
case ISOTROPIC:
logger->Info() << "Generating Second Order Isotropic Computation Kernel...\n";
return new SecondOrderComputationKernel(map);
}
logger->Error() << "No entry for wave->physics to identify Computation Kernel..." << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
logger->Error() << "No entry for wave->physics to identify Computation Kernel..." << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
ModelHandler *
ComponentsGenerator::GenerateModelHandler() {
JSONConfigurationMap *model_handler_map = this->TruncateMap(K_MODEL_HANDLER);
ModelHandler *model_handler;
model_handler = new SeismicModelHandler(model_handler_map);
return model_handler;
}
SourceInjector *
ComponentsGenerator::GenerateSourceInjector() {
auto logger = LoggerSystem::GetInstance();
if (this->mMap[K_SOURCE_INJECTOR].empty()) {
logger->Error() << "No entry for source-injector key : supported values [ ricker ]" << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
auto type = this->mMap[K_SOURCE_INJECTOR][OP_K_TYPE].get<string>();
auto map = this->TruncateMap(K_SOURCE_INJECTOR);
SourceInjector *source_injector;
if (type == "ricker") {
logger->Info() << "Generating Ricker Source Injector...\n";
source_injector = new RickerSourceInjector(map);
} else {
logger->Error() << "Invalid value for source-injector key : supported values [ ricker ]" << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
return source_injector;
}
BoundaryManager *
ComponentsGenerator::GenerateBoundaryManager() {
auto logger = LoggerSystem::GetInstance();
if (this->mMap[K_BOUNDARY_MANAGER].empty()) {
logger->Error() << "No entry for boundary-manager key : supported values "
<< K_SUPPORTED_VALUES_BOUNDARY_MANAGER << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
auto type = this->mMap[K_BOUNDARY_MANAGER][OP_K_TYPE].get<string>();
auto map = this->TruncateMap(K_BOUNDARY_MANAGER);
BoundaryManager *boundary_manager = nullptr;
if (type == "none") {
logger->Info() << "Generating None Boundary Manager...\n";
boundary_manager = new NoBoundaryManager(map);
} else if (type == "random") {
logger->Info() << "Generating Random Boundary Manager...\n";
boundary_manager = new RandomBoundaryManager(map);
} else if (type == "sponge") {
logger->Info() << "Generating Sponge Boundary Manager...\n";
boundary_manager = new SpongeBoundaryManager(map);
} else if (type == "cpml") {
if (this->mApproximation == ISOTROPIC) {
if (this->mOrder == FIRST) {
logger->Info() << "Generating Staggered First Order Isotropic CPML Boundary Manager...\n";
boundary_manager = new StaggeredCPMLBoundaryManager(map);
} else if (this->mOrder == SECOND) {
logger->Info() << "Generating Second Order Isotropic CPML Boundary Manager...\n";
boundary_manager = new CPMLBoundaryManager(map);
}
}
if (boundary_manager == nullptr) {
logger->Error() << "Invalid value for boundary-manager key : "
<< "Unsupported for this approximation/order pair" << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
}
if (boundary_manager == nullptr) {
logger->Error() << "Invalid value for boundary-manager key : supported values "
<< K_SUPPORTED_VALUES_BOUNDARY_MANAGER << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
return boundary_manager;
}
ForwardCollector *
ComponentsGenerator::GenerateForwardCollector(const string &write_path) {
auto logger = LoggerSystem::GetInstance();
if (this->mMap[K_FORWARD_COLLECTOR].empty()) {
logger->Error() << "No entry for forward-collector key : supported values "
<< K_SUPPORTED_VALUES_FORWARD_COLLECTOR << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
auto type = this->mMap[K_FORWARD_COLLECTOR][OP_K_TYPE].get<string>();
auto map = this->TruncateMap(K_FORWARD_COLLECTOR);
map->WriteValue(OP_K_PROPRIETIES, OP_K_WRITE_PATH, write_path);
ForwardCollector *forward_collector = nullptr;
if (type == "two") {
logger->Info() << "Generating Two Propagation Forward Collector...\n";
forward_collector = new TwoPropagation(map);
} else if (type == "three") {
logger->Info() << "Generating Three Propagation Forward Collector...\n";
forward_collector = new ReversePropagation(map);
}
if (forward_collector == nullptr) {
logger->Error() << "Invalid value for forward-collector key : supported values "
<< K_SUPPORTED_VALUES_FORWARD_COLLECTOR << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
return forward_collector;
}
MigrationAccommodator *
ComponentsGenerator::GenerateMigrationAccommodator() {
auto logger = LoggerSystem::GetInstance();
if (this->mMap[K_MIGRATION_ACCOMMODATOR].empty()) {
logger->Error() << "No entry for migration-accommodator key : supported values [ ""cross-correlation ]" << '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
auto type = this->mMap[K_MIGRATION_ACCOMMODATOR][OP_K_TYPE].get<string>();
auto map = this->TruncateMap(K_MIGRATION_ACCOMMODATOR);
MigrationAccommodator *correlation_kernel = nullptr;
if (type == "cross-correlation") {
logger->Info() << "Generating Cross Correlation Migration Accommodator...\n";
correlation_kernel = new CrossCorrelationKernel(map);
}
if (correlation_kernel == nullptr) {
logger->Error()
<< "Invalid value for migration-accommodator key : supported values [cross-correlation]"
<< '\n';
logger->Error() << "Terminating..." << '\n';
exit(EXIT_FAILURE);
}
return correlation_kernel;
}
TraceManager *
ComponentsGenerator::GenerateTraceManager() {
auto map = this->TruncateMap(K_TRACE_MANAGER);
TraceManager *trace_manager;
trace_manager = new SeismicTraceManager(map);
return trace_manager;
}
TraceWriter *
ComponentsGenerator::GenerateTraceWriter() {
auto map = this->TruncateMap(K_TRACE_WRITER);
TraceWriter *trace_writer;
trace_writer = new SeismicTraceWriter(map);
return trace_writer;
}
JSONConfigurationMap *
ComponentsGenerator::TruncateMap(const string &aComponentName) {
auto map = this->GetWaveMap();
map.merge_patch(this->mMap[aComponentName]);
return new JSONConfigurationMap(map);
}
nlohmann::json ComponentsGenerator::GetWaveMap() {
nlohmann::json map;
map[K_WAVE][K_APPROXIMATION] = this->mApproximation;
map[K_WAVE][K_SAMPLING] = this->mSampling;
map[K_WAVE][K_EQUATION_ORDER] = this->mOrder;
return map;
}
| 9,502
|
C++
|
.cpp
| 215
| 37.330233
| 120
| 0.650572
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,271
|
CallbacksGenerator.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/primitive/CallbacksGenerator.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/generators/primitive/CallbacksGenerator.hpp>
#include <stbx/generators/common/Keys.hpp>
#include <operations/helpers/callbacks/primitive/CallbackCollection.hpp>
#include <operations/helpers/callbacks/concrete/WriterCallback.h>
#include <operations/helpers/callbacks/concrete/NormWriter.h>
using namespace bs::base::logger;
using namespace stbx::generators;
using namespace operations::helpers::callbacks;
CallbacksGenerator::CallbacksGenerator(const std::string &aWritePath, nlohmann::json &aMap) {
this->mMap = aMap;
this->mWritePath = aWritePath;
this->mpCollection = new CallbackCollection();
}
CallbacksGenerator::~CallbacksGenerator() = default;
CallbackCollection *CallbacksGenerator::GenerateCallbacks() {
this->GetNormCallback();
this->GetWriterCallback();
return this->mpCollection;
}
CallbacksGenerator::WritersBooleans CallbacksGenerator::GenerateWritersConfiguration() {
struct CallbacksGenerator::WritersBooleans w;
nlohmann::json map = this->mMap[K_WRITERS_CONFIGURATION];
if (map[K_PARAMETERS][K_ENABLE].get<bool>()) {
w.WriteParams = true;
if (!map[K_PARAMETERS][K_OUTPUT].is_null()) {
w.VecParams = map[K_PARAMETERS][K_OUTPUT].get<std::vector<std::string>>();
}
}
if (map[K_FORWARD][K_ENABLE].get<bool>()) {
w.WriteForward = true;
}
if (map[K_BACKWARD][K_ENABLE].get<bool>()) {
w.WriteBackward = true;
}
if (map[K_REVERSE][K_ENABLE].get<bool>()) {
w.WriteReverse = true;
}
if (map[K_MIGRATION][K_ENABLE].get<bool>()) {
w.WriteMigration = true;
}
if (map[K_RE_EXTENDED_PARAMETERS][K_ENABLE].get<bool>()) {
w.WriteReExtendedParams = true;
if (!map[K_RE_EXTENDED_PARAMETERS][K_OUTPUT].is_null()) {
w.VecReExtendedParams = map[K_RE_EXTENDED_PARAMETERS][K_OUTPUT].get<std::vector<std::string>>();
}
}
if (map[K_SINGLE_SHOT_CORR][K_ENABLE].get<bool>()) {
w.WriteSingleShotCorrelation = true;
}
if (map[K_EACH_STACKED_SHOT][K_ENABLE].get<bool>()) {
w.WriteEachStackedShot = true;
}
if (map[K_TRACE_RAW][K_ENABLE].get<bool>()) {
w.WriteTracesRaw = true;
}
if (map[K_TRACES_PREPROCESSED][K_ENABLE].get<bool>()) {
w.WriteTracesPreprocessed = true;
}
return w;
}
void CallbacksGenerator::GetNormCallback() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
if (this->mMap[K_NORM][K_ENABLE].get<bool>()) {
int show_each = 200;
if (!this->mMap[K_NORM][K_SHOW_EACH].is_null()) {
show_each = this->mMap[K_NORM][K_SHOW_EACH].get<int>();
}
this->mpCollection->RegisterCallback(new NormWriter(show_each,
true,
true,
true,
this->mWritePath));
Logger->Info() << "Creating norm callback with show_each = " << show_each << '\n';
}
}
void CallbacksGenerator::GetWriterCallback() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
if (this->mMap[K_WRITER][K_ENABLE].get<bool>()) {
int show_each = 200;
if (!this->mMap[K_WRITER][K_SHOW_EACH].is_null()) {
show_each = this->mMap[K_WRITER][K_SHOW_EACH].get<int>();
}
std::vector<std::string> types;
std::vector<std::string> underlying_configurations;
if (!this->mMap[K_WRITER][K_ACTIVE_TYPES].is_null()) {
auto types_map = this->mMap[K_WRITER][K_ACTIVE_TYPES];
for (auto it = types_map.begin(); it != types_map.end(); ++it) {
auto object = it.value();
types.push_back(object.begin().key());
underlying_configurations.push_back(object.begin().value().dump());
}
}
CallbacksGenerator::WritersBooleans w = this->GenerateWritersConfiguration();
Logger->Info() << "Creating writer callback with show_each = " << show_each << '\n';
this->mpCollection->RegisterCallback(new WriterCallback(show_each,
w.WriteParams,
w.WriteForward,
w.WriteBackward,
w.WriteReverse,
w.WriteMigration,
w.WriteReExtendedParams,
w.WriteSingleShotCorrelation,
w.WriteEachStackedShot,
w.WriteTracesRaw,
w.WriteTracesPreprocessed,
w.VecParams,
w.VecReExtendedParams,
this->mWritePath,
types, underlying_configurations));
}
}
| 6,256
|
C++
|
.cpp
| 132
| 33.734848
| 108
| 0.555646
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,272
|
ComputationParametersGetter.cpp
|
brightskiesinc_Reverse_Time_Migration/src/generators/primitive/ComputationParametersGetter.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#include <stbx/generators/primitive/ComputationParametersGetter.hpp>
#include <stbx/generators/common/Keys.hpp>
#include <operations/common/DataTypes.h>
using namespace std;
using json = nlohmann::json;
using namespace bs::base::logger;
using namespace stbx::generators;
ComputationParametersGetter::ComputationParametersGetter(const json &aMap) : mMap(aMap) {}
Window ComputationParametersGetter::GetWindow() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Window w;
json window_map = this->mMap["window"];
if (window_map[K_ENABLE].get<bool>()) {
w.use_window = 1;
if (!window_map[K_LEFT].is_null()) {
w.left_win = window_map[K_LEFT].get<int>();
if (w.left_win < 0) {
Logger->Error() << "Invalid value entered for left window in x-direction: "
"must be positive..." << '\n';
w.left_win = DEF_VAL;
}
}
if (!window_map[K_RIGHT].is_null()) {
w.right_win = window_map[K_RIGHT].get<int>();
if (w.right_win < 0) {
Logger->Error() << "Invalid value entered for right window in x-direction: "
"must be positive..." << '\n';
w.right_win = DEF_VAL;
}
}
if (!window_map[K_DEPTH].is_null()) {
w.depth_win = window_map[K_DEPTH].get<int>();
if (w.depth_win < 0) {
Logger->Error() << "Invalid value entered for depth window in x-direction: "
"must be positive..." << '\n';
w.depth_win = DEF_VAL;
}
}
if (!window_map[K_FRONT].is_null()) {
w.front_win = window_map[K_FRONT].get<int>();
if (w.front_win < 0) {
Logger->Error() << "Invalid value entered for front window in x-direction: "
"must be positive..." << '\n';
w.front_win = DEF_VAL;
}
}
if (!window_map[K_BACK].is_null()) {
w.back_win = window_map[K_BACK].get<int>();
if (w.back_win < 0) {
Logger->Error() << "Invalid value entered for back window in x-direction: "
"must be positive..." << '\n';
w.back_win = DEF_VAL;
}
}
}
return w;
}
StencilOrder ComputationParametersGetter::GetStencilOrder() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
int value = this->mMap[K_STENCIL_ORDER].get<int>();
StencilOrder so;
switch (value) {
case 2:
so.order = 2;
so.half_length = O_2;
break;
case 4:
so.order = 4;
so.half_length = O_4;
break;
case 8:
so.order = 8;
so.half_length = O_8;
break;
case 12:
so.order = 12;
so.half_length = O_12;
break;
case 16:
so.order = 16;
so.half_length = O_16;
break;
default:
Logger->Error() << "Invalid order value entered for stencil..." << '\n';
Logger->Info() << "Supported values are : 2, 4, 8, 12, 16" << '\n';
break;
}
return so;
}
int ComputationParametersGetter::GetBoundaryLength() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
int value = this->mMap[K_BOUNDARY_LENGTH].get<int>();
if (value < 0) {
Logger->Error() << "Invalid value entered for boundary length: "
"must be positive or zero..." << '\n';
return DEF_VAL;
}
return value;
}
float ComputationParametersGetter::GetSourceFrequency() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
auto value = this->mMap[K_SOURCE_FREQUENCY].get<float>();
if (value < 0) {
Logger->Error() << "Invalid value entered for source frequency: must be positive..." << '\n';
return DEF_VAL;
}
return value;
}
float ComputationParametersGetter::GetDTRelaxed() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
auto value = this->mMap[K_DT_RELAX].get<float>();
if (value <= 0 || value > 1) {
Logger->Error() << "Invalid value entered for dt relaxation coefficient: must be larger than 0"
" and less than or equal 1..." << '\n';
return DEF_VAL;
}
return value;
}
int ComputationParametersGetter::GetBlock(const std::string &direction) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
json cache_blocking_map = this->mMap[K_CACHE_BLOCKING];
string block = "block-" + direction;
int value = cache_blocking_map[block].get<int>();
if (value <= 0) {
Logger->Error() << "Invalid value entered for block factor in "
<< direction << "-direction : must be positive..." << '\n';
return DEF_VAL;
}
return value;
}
int ComputationParametersGetter::GetIsotropicCircle() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
int value = this->mMap[K_ISOTROPIC_CIRCLE].get<int>();
if (value < 0) {
Logger->Error() << "Invalid value entered for isotropic circle coefficient: "
"Must be larger than 0" << '\n';
return DEF_VAL;
}
return value;
}
| 6,281
|
C++
|
.cpp
| 161
| 30.285714
| 103
| 0.579085
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,273
|
ArgumentsParser.cpp
|
brightskiesinc_Reverse_Time_Migration/src/parsers/ArgumentsParser.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <getopt.h>
#include <bs/base/api/cpp/BSBase.hpp>
#include <stbx/parsers/ArgumentsParser.hpp>
using namespace std;
using namespace bs::base::logger;
using namespace stbx::parsers;
void ArgumentsParser::Parse(std::string &aParameterFile,
std::string &aConfigurationFile,
std::string &aCallbackFile,
std::string &aSystem,
std::string &aWritePath,
int argc, char **argv) {
LoggerSystem *Logger = LoggerSystem::GetInstance();
int len = (int) string(WORKLOAD_PATH).length();
string new_workload_path;
int opt;
while ((opt = getopt(argc, argv, ":m:p:c:w:e:h")) != -1) {
switch (opt) {
case 'm':
new_workload_path = string(optarg);
aParameterFile.replace(aParameterFile.begin(),
aParameterFile.begin() + len,
new_workload_path);
aConfigurationFile.replace(aConfigurationFile.begin(),
aConfigurationFile.begin() + len,
new_workload_path);
aCallbackFile.replace(aCallbackFile.begin(),
aCallbackFile.begin() + len,
new_workload_path);
aSystem.replace(aSystem.begin(),
aSystem.begin() + len,
new_workload_path);
break;
case 'p':
aParameterFile = string(optarg);
break;
case 'c':
aCallbackFile = string(optarg);
break;
case 'e':
aConfigurationFile = string(optarg);
break;
case 'w':
aWritePath = string(optarg);
break;
case 'h':
ArgumentsParser::PrintHelp();
exit(EXIT_FAILURE);
case ':':
Logger->Error() << "Option needs a value" << '\n';
ArgumentsParser::PrintHelp();
exit(EXIT_FAILURE);
case '?':
default:
Logger->Error() << "\"Invalid option entered..." << '\n';
ArgumentsParser::PrintHelp();
exit(EXIT_FAILURE);
}
}
Logger->Info() << "Using files:" << '\n';
Logger->Info() << "\t- Computation parameters: " << aParameterFile << '\n';
Logger->Info() << "\t- Engine configurations: " << aConfigurationFile << '\n';
Logger->Info() << "\t- Callback configurations: " << aCallbackFile << '\n';
Logger->Info() << "\t- Write path: " << aWritePath << '\n';
}
void
ArgumentsParser::PrintHelp() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
Logger->Info() << "Usage:"
<< "\t ./Engine <optional-flags>"
<< "\nOptional flags:"
<< "\n\t-m <workload-path>"
"\n\t\tWorkloads configurations path."
"\n\t\tDefault is \"./workloads/bp_model\""
<< "\n\t-p <computation-parameter-file-path>"
"\n\t\tComputation parameter configurations path."
"\n\t\tDefault is \"./workloads/bp_model/computation_parameters.json\""
<< "\n\t-e <engine-configurations-file-path>"
"\n\t\tEngine configurations configurations path."
"\n\t\tDefault is \"./workloads/bp_model/engine_configuration.json\""
<< "\n\t-c <callbacks-configurations-file-path>"
"\n\t\tCallbacks configurations file path."
"\n\t\tDefault is \"./workloads/bp_model/callback_configuration.json\""
<< "\n\t-w <write path>"
"\n\t\tResults write path."
"\n\t\tDefault is \"./results\""
<< "\n\t-h"
"\n\t\tHelp window" << '\n';
}
| 4,908
|
C++
|
.cpp
| 107
| 31.766355
| 93
| 0.52133
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,274
|
Parser.cpp
|
brightskiesinc_Reverse_Time_Migration/src/parsers/Parser.cpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <dirent.h>
#include <string>
#include <fstream>
#include <bs/base/api/cpp/BSBase.hpp>
#include <stbx/parsers/Parser.hpp>
#define JSON_EXTENSION ".json"
using namespace std;
using json = nlohmann::json;
using namespace bs::base::logger;
using namespace stbx::parsers;
void Parser::RegisterFile(const std::string &file) {
this->mFiles.push_back(file);
}
void Parser::RegisterFolder(const std::string &folder) {
struct dirent *entry;
DIR *dp = opendir(folder.c_str());
if (dp != nullptr)
while ((entry = readdir(dp))) {
string file_name = entry->d_name;
if (file_name.find(JSON_EXTENSION) != string::npos) {
this->mFiles.push_back(folder + file_name);
}
}
}
json Parser::BuildMap() {
LoggerSystem *Logger = LoggerSystem::GetInstance();
vector<int> erase;
string extension = string(JSON_EXTENSION);
int size = this->mFiles.size();
Logger->Info() << "The following configuration files were detected : " << '\n';
for (int i = 0; i < size; i++) {
Logger->Info() << "\t" << (i + 1) << ". " << this->mFiles[i] << '\n';
if (this->mFiles[i].substr(this->mFiles[i].size() - extension.size()) != extension) {
Logger->Info() << "\tRegistered file extension is not supported..." << '\n';
erase.push_back(i);
}
}
for (int &i:erase) {
this->mFiles.erase(this->mFiles.begin() + i);
}
for (string &f : this->mFiles) {
std::ifstream in(f.c_str());
json temp;
in >> temp;
this->mMap.merge_patch(temp);
}
return this->mMap;
}
json Parser::GetMap() {
return this->mMap;
}
const vector<std::string> &Parser::GetFiles() const {
return this->mFiles;
}
| 2,553
|
C++
|
.cpp
| 73
| 30.452055
| 93
| 0.652755
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,275
|
Agents.h
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/Agents.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_AGENTS_H
#define PIPELINE_AGENTS_AGENTS_H
#include <stbx/agents/interface/Agent.hpp>
#include <stbx/agents/concrete/NormalAgent.hpp>
#include <stbx/agents/concrete/StaticServerlessAgent.hpp>
#include <stbx/agents/concrete/StaticServerAgent.hpp>
#include <stbx/agents/concrete/DynamicServerlessAgent.hpp>
#include <stbx/agents/concrete/DynamicServerAgent.hpp>
#endif //PIPELINE_AGENTS_AGENTS_H
| 1,179
|
C++
|
.h
| 27
| 41.888889
| 76
| 0.790941
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,276
|
NormalAgent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/concrete/NormalAgent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_NORMAL_AGENT_HPP
#define PIPELINE_AGENTS_NORMAL_AGENT_HPP
#include <stbx/agents/interface/Agent.hpp>
namespace stbx {
namespace agents {
/**
* @brief
*/
class NormalAgent : public Agent {
public:
/**
* @brief Constructor.
*/
NormalAgent() = default;
/**
* @brief Destructor.
*/
~NormalAgent() override;
/**
* @brief Initialize member variables assigned to
* each derived class.
* <br>
* Should always be called in each derived class as follows:-
* GridBox *gb = Agent::Initialize();
* and return gb at the end of each derived Initialize function.
*
* @return GridBox*
*/
operations::dataunits::GridBox *Initialize() override;
/**
* @brief Preform all tasks need by the engine before migration.
*/
void BeforeMigration() override;
/**
* @brief Preform all tasks need by the engine after migration.
*/
void AfterMigration() override;
/**
* @brief Preform all tasks need by the engine
* before finalizing migration.
*/
void BeforeFinalize() override;
/**
* @brief Preform all tasks need by the engine
* after finalizing migration.
* @param[in] aMigrationData : MigrationData
*/
operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *aMigrationData) override;
bool HasNextShot() override;
std::vector<uint> GetNextShot() override;
private:
uint mCount = 0;
};
}//namespace agents
}//namespace stbx
#endif //PIPELINE_AGENTS_NORMAL_AGENT_HPP
| 2,751
|
C++
|
.h
| 75
| 27.56
| 83
| 0.60188
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,277
|
StaticServerlessAgent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/concrete/StaticServerlessAgent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_STATIC_SERVERLESS_HPP
#define PIPELINE_AGENTS_STATIC_SERVERLESS_HPP
#if defined(USING_MPI)
#include <stbx/agents/interface/Agent.hpp>
#include <mpi.h>
namespace stbx {
namespace agents {
class StaticServerlessAgent : public Agent {
public:
StaticServerlessAgent();
~StaticServerlessAgent() override;
operations::dataunits::GridBox *Initialize() override;
void BeforeMigration() override;
void AfterMigration() override;
void BeforeFinalize() override;
operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *apMigrationData) override;
bool HasNextShot() override;
std::vector<uint> GetNextShot() override;
private:
uint mCount;
operations::dataunits::GridBox *mpGridBox;
/// Current process rank is stored in self
int self, mProcessCount;
/// MPI communicator
MPI_Comm mCommunication;
/// Shots vector
std::vector<uint> mPossibleShots;
std::vector<float *> mStacks;
};
}//namespace agents
}//namespace stbx
#endif
#endif //PIPELINE_AGENTS_STATIC_SERVERLESS_HPP
| 2,077
|
C++
|
.h
| 52
| 32.865385
| 84
| 0.686314
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,278
|
DynamicServerlessAgent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/concrete/DynamicServerlessAgent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_DYNAMIC_SERVERLESS_HPP
#define PIPELINE_AGENTS_DYNAMIC_SERVERLESS_HPP
#if defined(USING_MPI)
#include <stbx/agents/interface/Agent.hpp>
#include <mpi.h>
namespace stbx {
namespace agents {
class DynamicServerlessAgent : public Agent {
public:
DynamicServerlessAgent() = default;
~DynamicServerlessAgent() override;
operations::dataunits::GridBox *Initialize() override;
void BeforeMigration() override;
void AfterMigration() override;
void BeforeFinalize() override;
operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *apMigrationData) override;
bool HasNextShot() override;
std::vector<uint> GetNextShot() override;
private:
uint mCount = 0;
/// Current process rank is stored in self
int self, mProcessCount;
/// MPI communicator
MPI_Comm mCommunication;
/// Reception operation status
MPI_Status mStatus;
/// Original shot size
uint mShotsSize;
uint mMasterCurrentShotID;
/// Current shot ID to be processed
int mShotTracker = 0;
/// Indicate the first shots iterators
int mShotsCount = 0;
/// All shots vector
std::vector<uint> mPossibleShots;
/// Shots per each process
std::vector<uint> mProcessShots;
std::vector<float *> mStacks;
operations::dataunits::GridBox *mpGridBox;
bool mHasShotDynamic = false;
/**
* ==============================================
* Flags used for the master slave communication.
* ==============================================
*
* flag[0] -> Shot ID (from server to clients).
*
* flag[1] -> Shot flag (from server to clients):
* - 0 = There are shots available
* - 1 = All shots are migrated
*
* flag[2] -> Availability flag (from clients to server):
* - 0 = Still working
* - 1 = Available now
*
* flag[3] -> Rank flag (from clients to server)
*
* flag[4] -> Migration flag (from server to clients):
* - 0 = For a process if (process rank < # of shots) -> It will be working on a shot
* - 1 = If (process rank >= Number of shots) -> There is no enough shots for this process
*/
int flag[5] = {0, 0, 0, 0, 0};
};
}//namespace agents
}//namespace stbx
#endif
#endif //PIPELINE_AGENTS_DYNAMIC_SERVERLESS_HPP
| 3,620
|
C++
|
.h
| 86
| 32.360465
| 106
| 0.584475
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,279
|
DynamicServerAgent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/concrete/DynamicServerAgent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_DYNAMIC_SERVER_HPP
#define PIPELINE_AGENTS_DYNAMIC_SERVER_HPP
#if defined(USING_MPI)
#include <stbx/agents/interface/Agent.hpp>
#include <mpi.h>
namespace stbx {
namespace agents {
class DynamicServerAgent : public Agent {
public:
DynamicServerAgent() = default;
~DynamicServerAgent() override;
operations::dataunits::GridBox *Initialize() override;
void BeforeMigration() override;
void AfterMigration() override;
void BeforeFinalize() override;
operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *apMigrationData) override;
bool HasNextShot() override;
std::vector<uint> GetNextShot() override;
private:
uint mCount;
/// Current process rank is stored in self
int self, mProcessCount;
/// the MPI communicator
MPI_Comm mCommunication;
/// Reception operation status
MPI_Status mStatus;
/// All shots vector
std::vector<uint> mPossibleShots;
/// Shots per each process
std::vector<uint> mProcessShots;
/// Original shot size
uint mShotsSize;
/// Current shot ID to be processed
int mShotTracker = 0;
/// Indicate the first shots iterators
int mShotsCount = 0;
operations::dataunits::GridBox *mpGridBox;
std::vector<float *> mStacks;
/**
* ==============================================
* Flags used for the master slave communication.
* ==============================================
*
* flag[0] -> Shot ID (from server to clients).
*
* flag[1] -> Shot flag (from server to clients):
* - 0 = There are shots available
* - 1 = All shots are migrated
*
* flag[2] -> Availability flag (from clients to server):
* - 0 = Still working
* - 1 = Available now
*
* flag[3] -> Rank flag (from clients to server)
*
* flag[4] -> Migration flag (from server to clients):
* - 0 = For a process if (process rank < # of shots) -> It will be working on a shot
* - 1 = If (process rank >= Number of shots) -> There is no enough shots for this process
*/
int flag[5] = {0, 0, 0, 0, 0};
};
}//namespace agents
}//namespace stbx
#endif
#endif //PIPELINE_AGENTS_DYNAMIC_SERVER_HPP
| 3,514
|
C++
|
.h
| 84
| 32.190476
| 106
| 0.581594
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,280
|
StaticServerAgent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/concrete/StaticServerAgent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_STATIC_SERVER_HPP
#define PIPELINE_AGENTS_STATIC_SERVER_HPP
#if defined(USING_MPI)
#include <stbx/agents/interface/Agent.hpp>
#include <mpi.h>
namespace stbx {
namespace agents {
class StaticServerAgent : public Agent {
public:
StaticServerAgent();
~StaticServerAgent() override;
operations::dataunits::GridBox *Initialize() override;
void BeforeMigration() override;
void AfterMigration() override;
void BeforeFinalize() override;
operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *apMigrationData) override;
bool HasNextShot() override;
std::vector<uint> GetNextShot() override;
private:
uint mCount;
operations::dataunits::GridBox *mpGridBox;
/// Current process rank is stored in self
int self, mProcessCount;
/// MPI communicator
MPI_Comm mCommunication;
/// Shots vector
std::vector<uint> mPossibleShots;
std::vector<float *> mStacks;
};
}//namespace agents
}//namespace stbx
#endif
#endif //PIPELINE_AGENTS_STATIC_SERVER_HPP
| 2,052
|
C++
|
.h
| 52
| 32.403846
| 84
| 0.682508
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,281
|
Agent.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/agents/interface/Agent.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_AGENTS_AGENT_HPP
#define PIPELINE_AGENTS_AGENT_HPP
#include <operations/engines/interface/Engine.hpp>
namespace stbx {
namespace agents {
/**
* @brief After specifying which running approach is currently
* being used (i.e. MPI/No MPI), Agent is responsible to preform
* RTMEngine tasks accordingly.
*
* @note Should be inherited whenever a new approach is used
*/
class Agent {
public:
/**
* @brief Constructor should be overridden to
* initialize needed member variables.
*/
Agent() = default;
/**
* @brief Destructor should be overridden to
* ensure correct memory management.
*/
virtual ~Agent() = default;
/**
* @brief Assign initialized engine to agent to use in
* all functions.
* @param aEngine : RTMEngine
*/
inline void AssignEngine(operations::engines::Engine *aEngine) {
mpEngine = aEngine;
}
/**
* @brief Assign CLI arguments to agent to use in
* all functions.
* @param _argc
* @param _argv
*/
inline void AssignArgs(int _argc, char **_argv) {
argc = _argc;
argv = _argv;
}
/**
* @brief Initialize member variables assigned to
* each derived class.
* <br>
* Should always be called in each derived class as follows:-
* GridBox *gb = Agent::Initialize();
* and return gb at the end of each derived Initialize function.
*
* @return GridBox*
*/
virtual operations::dataunits::GridBox *Initialize() {
return mpEngine->Initialize();
}
/**
* @brief Preform all tasks need by the engine before migration.
*/
virtual void BeforeMigration() = 0;
/**
* @brief Preform all tasks need by the engine after migration.
*/
virtual void AfterMigration() = 0;
/**
* @brief Preform all tasks need by the engine
* before finalizing migration.
*/
virtual void BeforeFinalize() = 0;
/**
* @brief Preform all tasks need by the engine
* after finalizing migration.
* @param[in] apMigrationData : MigrationData *
*/
virtual operations::dataunits::MigrationData *AfterFinalize(
operations::dataunits::MigrationData *apMigrationData) = 0;
virtual bool HasNextShot() = 0;
virtual std::vector<uint> GetNextShot() = 0;
/**
* @brief Preform migration full cycle.
* @return aMigrationData : MigrationData
*/
operations::dataunits::MigrationData *Execute() {
operations::dataunits::GridBox *gb = Initialize();
BeforeMigration();
while (HasNextShot()) {
mpEngine->MigrateShots(GetNextShot(), gb);
AfterMigration();
}
BeforeFinalize();
operations::dataunits::MigrationData *finalized_data = AfterFinalize(mpEngine->Finalize(gb));
return finalized_data;
}
protected:
/// Engine instance needed by agent to preform task upon
operations::engines::Engine *mpEngine{};
/// CLI arguments
int argc{};
char **argv{};
};
}//namespace agents
}//namespace stbx
#endif //PIPELINE_AGENTS_AGENT_HPP
| 4,666
|
C++
|
.h
| 120
| 27.558333
| 109
| 0.560292
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,282
|
Writers.h
|
brightskiesinc_Reverse_Time_Migration/include/stbx/writers/Writers.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_WRITERS_WRITERS_H
#define PIPELINE_WRITERS_WRITERS_H
#include <stbx/writers/interface/Writer.hpp>
#include <stbx/writers/concrete/NormalWriter.hpp>
#endif //PIPELINE_WRITERS_WRITERS_H
| 962
|
C++
|
.h
| 23
| 39.956522
| 76
| 0.777778
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,283
|
NormalWriter.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/writers/concrete/NormalWriter.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_WRITERS_NORMAL_WRITER_HPP
#define PIPELINE_WRITERS_NORMAL_WRITER_HPP
#include <stbx/writers/interface/Writer.hpp>
namespace stbx {
namespace writers {
class NormalWriter : public Writer {
public:
NormalWriter() = default;
~NormalWriter() override = default;
private:
void SpecifyRawMigration() override;
void Initialize() override {};
void PostProcess() override;
};
}//namespace writers
}//namespace stbx
#endif //PIPELINE_WRITERS_NORMAL_WRITER_HPP
| 1,334
|
C++
|
.h
| 35
| 33.514286
| 76
| 0.72093
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,284
|
Writer.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/writers/interface/Writer.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPELINE_WRITERS_WRITER_HPP
#define PIPELINE_WRITERS_WRITER_HPP
#include <fstream>
#include <sys/stat.h>
#include <operations/engines/concrete/RTMEngine.hpp>
#include <operations/common/DataTypes.h>
#include <operations/utils/io/write_utils.h>
#include <operations/utils/filters/noise_filtering.h>
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <bs/timer/api/cpp/BSTimer.hpp>
#include <bs/io/api/cpp/BSIO.hpp>
using namespace bs::timer;
using namespace bs::timer::configurations;
namespace stbx {
namespace writers {
/**
* @brief Writer class is used to write various types
* of formats for a given migration data
*
* @note Should be inherited whenever a new approach is used
*/
class Writer {
public:
/**
* @brief Constructor could be overridden to
* initialize needed member variables.
*/
Writer() : mFilteredMigration(nullptr), mRawMigration(nullptr), mpMigrationData(nullptr) {
this->mOutputTypes = {"binary", "segy"};
}
/**
* @brief Destructor should be overridden to
* ensure correct memory management.
*/
virtual ~Writer() {
delete[] mRawMigration;
};
/**
* @brief Assign initialized engine to agent to use in
* all functions.
* @param aEngine : RTMEngine
*/
inline void AssignMigrationData(operations::dataunits::MigrationData *apMigrationData) {
this->mpMigrationData = apMigrationData;
}
virtual void Write(const std::string &aWritePath, bool is_traces = false) {
mkdir(aWritePath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
this->SpecifyRawMigration();
this->PostProcess();
this->Filter();
this->WriteFrame(mRawMigration, aWritePath + "/raw_migration");
this->WriteFrame(mFilteredMigration, aWritePath + "/filtered_migration");
this->WriteTimeResults(aWritePath);
}
/**
* @brief Writes time results performed by Timer.
* @param aWritePath : string File name to be written.
*/
void WriteTimeResults(const std::string &aWritePath) {
std::vector<std::ostream *> streams;
streams.emplace_back(&std::cout);
std::ofstream ofs;
ofs.open(aWritePath + "/timing_results.txt");
streams.emplace_back(&ofs);
TimerManager::GetInstance()->Report(streams);
ofs.close();
}
protected:
/**
* @brief Initialize member variables assigned to
* each derived class.
*/
virtual void Initialize() = 0;
/**
* @brief Preprocess migration data before starting
* to write.
*/
virtual void PostProcess() = 0;
/**
* @brief Extracts migration results from provided
* Migration Data.
* @return Migration results
*/
virtual void SpecifyRawMigration() {};
/**
* @brief Filter migration data into
* @note *mpMigrationData will be internally used
* @param frame : float * Frame to be filtered
*/
virtual void Filter() {
uint nx = this->mpMigrationData->GetGridSize(X_AXIS);
uint ny = this->mpMigrationData->GetGridSize(Y_AXIS);
uint nz = this->mpMigrationData->GetGridSize(Z_AXIS);
mFilteredMigration = new float[nx * ny * nz];
{
ScopeTimer t("Writer::FilterMigration");
operations::utils::filters::filter_stacked_correlation(
this->mRawMigration,
this->mFilteredMigration,
nx, ny, nz,
this->mpMigrationData->GetCellDimensions(X_AXIS),
this->mpMigrationData->GetCellDimensions(Y_AXIS),
this->mpMigrationData->GetCellDimensions(Z_AXIS));
}
};
/**
* @brief Writes migration data into the specified format
* @note *mpMigrationData will be internally used
* @param file_name : string File name to be written.
* @param is_traces : bool Check
*/
virtual void WriteFrame(float *frame, const std::string &file_name, uint shots = 1) {
uint ns;
float ds;
float sample_rate;
ns = this->mpMigrationData->GetGridSize(Z_AXIS);
ds = this->mpMigrationData->GetCellDimensions(Z_AXIS);
sample_rate = 1e3;
auto gathers = operations::utils::io::TransformToGather(
frame,
this->mpMigrationData->GetGridSize(X_AXIS),
this->mpMigrationData->GetGridSize(Y_AXIS),
ns,
ds,
this->mpMigrationData->GetMetadataGather(),
shots,
sample_rate
);
for (auto &output_type : this->mOutputTypes) {
std::string path = file_name;
bs::base::configurations::JSONConfigurationMap map({});
bs::io::streams::SeismicWriter writer(
bs::io::streams::SeismicWriter::ToWriterType(output_type), &map);
writer.AcquireConfiguration();
writer.Initialize(path);
writer.Write(gathers);
writer.Finalize();
}
for (auto g : gathers) {
delete g;
}
}
protected:
/// Engine instance needed by agent to preform task upon
operations::dataunits::MigrationData *mpMigrationData;
float *mFilteredMigration;
float *mRawMigration;
std::vector<std::string> mOutputTypes;
};
}//namespace writers
}//namespace stbx
#endif //PIPELINE_WRITERS_WRITER_HPP
| 7,332
|
C++
|
.h
| 170
| 29.947059
| 102
| 0.553206
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,285
|
Generator.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/Generator.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_GENERATORS_GENERATOR_HPP
#define SEISMIC_TOOLBOX_GENERATORS_GENERATOR_HPP
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <operations/common/DataTypes.h>
#include <operations/components/Components.hpp>
#include <operations/engine-configurations/concrete/RTMEngineConfigurations.hpp>
#include <operations/engine-configurations/concrete/ModellingEngineConfigurations.hpp>
#include <operations/engines/concrete/RTMEngine.hpp>
#include <operations/engines/concrete/ModellingEngine.hpp>
#include <operations/helpers/callbacks/primitive/CallbackCollection.hpp>
#include <stbx/generators/primitive/ConfigurationsGenerator.hpp>
#include <stbx/writers/Writers.h>
#include <stbx/agents/Agents.h>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <map>
namespace stbx {
namespace generators {
class Generator {
public:
/**
* @brief Constructor.
*/
explicit Generator(const nlohmann::json &aMap);
/**
* @brief Destructor ensures correct memory management.
*/
~Generator() = default;
/**
* @brief Extracts algorithm from system configurations file
* to generate appropriate Engine instance.
* @return Engine Engine instance
*/
operations::engines::Engine *
GenerateEngine(const std::string &aWritePath);
/**
* @brief Extracts algorithm from system configurations file
* to generate appropriate Engine Configuration instance.
* @return EngineConfiguration EngineConfiguration instance
*/
operations::configurations::EngineConfigurations *
GenerateEngineConfiguration(const std::string &aWritePath);
/**
* @brief Extracts of Modelling Engine Configuration
* component from parsed map and returns Configuration instance.
* @return ModellingEngineConfiguration instance
*/
operations::configurations::ModellingEngineConfigurations *
GenerateModellingEngineConfiguration(const std::string &aWritePath);
/**
* @brief Extracts of Engine Configuration
* component from parsed map and returns Writer instance.
* @return EngineConfiguration EngineConfiguration instance
*/
operations::configurations::RTMEngineConfigurations *
GenerateRTMConfiguration(const std::string &aWritePath);
/**
* @brief Extracts of Callbacks component from parsed map
* and returns CallbackCollection instance.
* @return CallbackCollection CallbackCollection instance
*/
operations::helpers::callbacks::CallbackCollection *
GenerateCallbacks(const std::string &aWritePath);
/**
* @brief Extracts of Computation Parameters
* component from parsed map and returns Writer instance.
* @return ComputationParameters ComputationParameters instance
*/
operations::common::ComputationParameters *
GenerateParameters();
/**
* @brief Extracts of Agent component from parsed map
* and returns Writer instance.
* @return Agent Agent instance
*/
agents::Agent *
GenerateAgent();
/**
* @brief Extracts of Writer component from parsed map
* and returns Writer instance.
* @return Writer Writer instance
*/
writers::Writer *
GenerateWriter();
/**
* @brief Extracts timer properties from map and returns timer configuration.
* @return JSONConfigurationMap: Timer configuration map
*/
bs::base::configurations::ConfigurationMap *
GenerateTimerConfiguration();
private:
/// Map that holds configurations key value pairs
nlohmann::json mMap;
EQUATION_ORDER mOrder;
GRID_SAMPLING mSampling;
APPROXIMATION mApproximation;
ConfigurationsGenerator *mConfigurationsGenerator;
};
}//namespace generators
}//namespace stbx
#endif //SEISMIC_TOOLBOX_GENERATORS_GENERATOR_HPP
| 5,290
|
C++
|
.h
| 118
| 35.118644
| 89
| 0.654503
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,286
|
computation_parameters_generator.h
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/concrete/computation-parameters/computation_parameters_generator.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_GENERATORS_COMPUTATION_PARAMETERS_COMPUTATION_PARAMETERS_GENERATOR_H
#define SEISMIC_TOOLBOX_GENERATORS_COMPUTATION_PARAMETERS_COMPUTATION_PARAMETERS_GENERATOR_H
#include <operations/common/ComputationParameters.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
operations::common::ComputationParameters *generate_parameters(nlohmann::json &aMap);
#endif // SEISMIC_TOOLBOX_GENERATORS_COMPUTATION_PARAMETERS_COMPUTATION_PARAMETERS_GENERATOR_H
| 1,238
|
C++
|
.h
| 24
| 49.666667
| 94
| 0.80397
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,287
|
Keys.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/common/Keys.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_GENERATORS_KEYS_H
#define SEISMIC_TOOLBOX_GENERATORS_KEYS_H
#define DEF_VAL -1
/*
* COMMON
*/
#define K_ENABLE "enable"
#define OP_K_TYPE "type"
/*
* CONFIGURATIONS
*/
#define K_CALLBACKS "callbacks"
#define K_COMPUTATION_PARAMETERS "computation-parameters"
#define K_TRACES "traces"
#define K_MODELS "models"
#define K_WAVE "wave"
#define K_PHYSICS "physics"
#define K_APPROXIMATION "approximation"
#define K_EQUATION_ORDER "equation-order"
#define K_SAMPLING "sampling"
#define K_GRID_SAMPLING "grid-sampling"
// Model Files
#define K_DENSITY "density"
#define K_DELTA "delta"
#define K_EPSILON "epsilon"
#define K_THETA "theta"
#define K_PHI "phi"
// Files
#define K_MIN "min"
#define K_MAX "max"
#define K_SORT_TYPE "sort-type"
#define K_PATHS "paths"
#define K_MODELLING_FILE "modelling-file"
#define K_OUTPUT_FILE "output-file"
/*
* COMPUTATION PARAMETERS
*/
#define K_WINDOW "window"
#define K_LEFT "left"
#define K_RIGHT "right"
#define K_DEPTH "depth"
#define K_FRONT "front"
#define K_BACK "back"
#define K_STENCIL_ORDER "stencil-order"
#define K_BOUNDARY_LENGTH "boundary-length"
#define K_SOURCE_FREQUENCY "source-frequency"
#define K_DT_RELAX "dt-relax"
#define K_CACHE_BLOCKING "cache-blocking"
#define K_ISOTROPIC_CIRCLE "isotropic-radius"
/*
* CALLBACKS
*/
#define K_SHOW_EACH "show-each"
#define K_NORM "norm"
#define K_BIN "bin"
#define K_CSV "csv"
#define K_SEGY "segy"
#define K_SU "su"
#define K_IMAGE "image"
#define K_NORM "norm"
#define K_PERC "percentile"
#define K_LITTLE_ENDIAN "little-endian"
#define K_WRITER "writer"
#define K_ACTIVE_TYPES "active-types"
#define K_WRITERS_CONFIGURATION "writers-configuration"
#define K_PARAMETERS "parameters"
#define K_VELOCITY "velocity"
#define K_FORWARD "forward"
#define K_BACKWARD "backward"
#define K_REVERSE "reverse"
#define K_MIGRATION "migration"
#define K_RE_EXTENDED_PARAMETERS "re-extended-parameters"
#define K_SINGLE_SHOT_CORR "single-shot-correlation"
#define K_EACH_STACKED_SHOT "each-stacked-shot"
#define K_TRACE_RAW "traces-raw"
#define K_TRACES_PREPROCESSED "traces-preprocessed"
#define K_OUTPUT "output"
/*
* COMPONENTS
*/
#define K_COMPONENTS "components"
#define K_COMPUTATION_KERNEL "computation-kernel"
#define K_BOUNDARY_MANAGER "boundary-manager"
#define K_MIGRATION_ACCOMMODATOR "migration-accommodator"
#define K_FORWARD_COLLECTOR "forward-collector"
#define K_TRACE_MANAGER "trace-manager"
#define K_SOURCE_INJECTOR "source-injector"
#define K_MODEL_HANDLER "model-handler"
#define K_TRACE_WRITER "trace-writer"
#define K_MODELLING_CONFIGURATION_PARSER "modelling-configuration-parser"
/*
* SYSTEM
*/
#define K_SYSTEM "system"
#define K_AGENT "agent"
#define K_WRITER "writer"
#define K_ALGORITHM "algorithm"
#define K_TIMER "timer"
#define K_TIMER_PROPERTIES "properties"
#define K_TIME_UNIT "precision"
/*
* SUPPORTED VALUES
*/
#define K_SUPPORTED_VALUES_BOUNDARY_MANAGER "[ none | random | sponge | cpml ]"
#define K_SUPPORTED_VALUES_FORWARD_COLLECTOR "[ two | three ]"
#endif //SEISMIC_TOOLBOX_GENERATORS_KEYS_H
| 5,624
|
C++
|
.h
| 124
| 43.935484
| 79
| 0.520168
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,288
|
ComponentsGenerator.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/primitive/ComponentsGenerator.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STBX_GENERATORS_COMPONENTS_COMPONENTS_GENERATOR
#define STBX_GENERATORS_COMPONENTS_COMPONENTS_GENERATOR
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
#include <operations/common/DataTypes.h>
#include <operations/components/Components.hpp>
namespace stbx {
namespace generators {
class ComponentsGenerator {
public:
explicit ComponentsGenerator(const nlohmann::json &aMap,
EQUATION_ORDER aOrder,
GRID_SAMPLING aSampling,
APPROXIMATION aApproximation);
~ComponentsGenerator() = default;
operations::components::ComputationKernel *
GenerateComputationKernel();
operations::components::ModelHandler *
GenerateModelHandler();
operations::components::SourceInjector *
GenerateSourceInjector();
operations::components::BoundaryManager *
GenerateBoundaryManager();
operations::components::ForwardCollector *
GenerateForwardCollector(const std::string &write_path);
operations::components::MigrationAccommodator *
GenerateMigrationAccommodator();
operations::components::TraceManager *
GenerateTraceManager();
operations::components::TraceWriter *
GenerateTraceWriter();
private:
bs::base::configurations::JSONConfigurationMap *
TruncateMap(const std::string &aComponentName);
nlohmann::json
GetWaveMap();
private:
/// Map that holds configurations key value pairs
nlohmann::json mMap;
EQUATION_ORDER mOrder;
GRID_SAMPLING mSampling;
APPROXIMATION mApproximation;
};
}// namespace generators
}//namesapce stbx
#endif //STBX_GENERATORS_COMPONENTS_COMPONENTS_GENERATOR
| 2,760
|
C++
|
.h
| 63
| 34.380952
| 76
| 0.671023
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,289
|
CallbacksGenerator.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/primitive/CallbacksGenerator.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STBX_GENERATORS_CALLBACKS_CALLBACKS_GENERATOR
#define STBX_GENERATORS_CALLBACKS_CALLBACKS_GENERATOR
#include <operations/helpers/callbacks/primitive/CallbackCollection.hpp>
#include <operations/common/DataTypes.h>
#include <operations/components/Components.hpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <vector>
#include <string>
namespace stbx {
namespace generators {
class CallbacksGenerator {
public:
CallbacksGenerator(const std::string &aWritePath, nlohmann::json &aMap);
~CallbacksGenerator();
operations::helpers::callbacks::CallbackCollection *
GenerateCallbacks();
private:
struct WritersBooleans {
bool WriteParams = false,
WriteForward = false,
WriteBackward = false,
WriteReverse = false,
WriteMigration = false,
WriteReExtendedParams = false,
WriteSingleShotCorrelation = false,
WriteEachStackedShot = false,
WriteTracesRaw = false,
WriteTracesPreprocessed = false;
std::vector<std::string> VecParams;
std::vector<std::string> VecReExtendedParams;
};
private:
CallbacksGenerator::WritersBooleans
GenerateWritersConfiguration();
void
GetNormCallback();
void
GetWriterCallback();
private:
std::string mWritePath;
nlohmann::json mMap;
operations::helpers::callbacks::CallbackCollection *mpCollection;
};
}// namespace generators
}//namesapce stbx
#endif //STBX_GENERATORS_CALLBACKS_CALLBACKS_GENERATOR
| 2,615
|
C++
|
.h
| 64
| 31.546875
| 84
| 0.65418
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,290
|
ConfigurationsGenerator.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/primitive/ConfigurationsGenerator.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STBX_GENERATORS_CONFIGURATIONS_CONFIGURATIONS_GENERATOR_H
#define STBX_GENERATORS_CONFIGURATIONS_CONFIGURATIONS_GENERATOR_H
#include <operations/common/DataTypes.h>
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <map>
namespace stbx {
namespace generators {
class ConfigurationsGenerator {
public:
explicit ConfigurationsGenerator(nlohmann::json &aMap);
~ConfigurationsGenerator() = default;
PHYSICS
GetPhysics();
EQUATION_ORDER
GetEquationOrder();
GRID_SAMPLING
GetGridSampling();
APPROXIMATION
GetApproximation();
std::map<std::string, std::string>
GetModelFiles();
std::vector<std::string>
GetTraceFiles();
uint GetTracesMin();
uint GetTracesMax();
std::string GetTracesSortKey();
private:
/// Map that holds configurations key value pairs
nlohmann::json mMap;
};
}//namespace generators
}//namespace stbx
#endif //STBX_GENERATORS_CONFIGURATIONS_CONFIGURATIONS_GENERATOR_H
| 1,943
|
C++
|
.h
| 51
| 31.156863
| 76
| 0.687834
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,291
|
ComputationParametersGetter.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/generators/primitive/ComputationParametersGetter.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_COMPUTATIONPARAMETERSGETTER_HPP
#define SEISMIC_TOOLBOX_COMPUTATIONPARAMETERSGETTER_HPP
#include <stbx/generators/common/Keys.hpp>
#include <operations/common/DataTypes.h>
#include <prerequisites/libraries/nlohmann/json.hpp>
namespace stbx {
namespace generators {
struct Window {
int use_window = 0;
int left_win = DEF_VAL;
int right_win = DEF_VAL;
int front_win = DEF_VAL;
int back_win = DEF_VAL;
int depth_win = DEF_VAL;
};
struct StencilOrder {
int order = DEF_VAL;
HALF_LENGTH half_length = O_8;
};
class ComputationParametersGetter {
public:
explicit ComputationParametersGetter(const nlohmann::json &aMap);
~ComputationParametersGetter() = default;
Window GetWindow();
StencilOrder GetStencilOrder();
int GetBoundaryLength();
float GetSourceFrequency();
float GetDTRelaxed();
int GetBlock(const std::string &direction);
int GetIsotropicCircle();
private:
nlohmann::json mMap;
};
};// namespace generators
}//namesapce stbx
#endif //SEISMIC_TOOLBOX_COMPUTATIONPARAMETERSGETTER_HPP
| 2,077
|
C++
|
.h
| 54
| 31.444444
| 77
| 0.678482
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,292
|
Parser.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/parsers/Parser.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_PARSERS_PARSER_HPP
#define SEISMIC_TOOLBOX_PARSERS_PARSER_HPP
#include <operations/common/Singleton.tpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
namespace stbx {
namespace parsers {
/**
* @brief Parser class responsible for registering .json files
* to be parsed or a whole folder to parse all .json files inside.
* <br>
* Variant parsing functions are implemented to provide extraction of
* some components from parsed map and return specific object instance.
*/
class Parser : public operations::common::Singleton<Parser> {
public:
friend class Singleton<Parser>;
public:
/**
* @brief Builds cne big map containing all registered files
* key values pairs.
* @return Map : json -> json::Value
*/
nlohmann::json
BuildMap();
/**
* @brief Registers a given .json files to be parsed.
* @param folder : string File path to be parsed
*/
void
RegisterFile(const std::string &file);
const std::vector<std::string> &
GetFiles() const;
/**
* @brief Registers all .json files found inside a folder.
* @param folder : string Folder path to be parsed
*/
void
RegisterFolder(const std::string &folder);
/**
* @brief Map getter.
* @return Map : json -> json::Value
*/
nlohmann::json
GetMap();
private:
/// Map that holds configurations key value pairs
nlohmann::json mMap;
/// Registered files to be parsed.
std::vector<std::string> mFiles;
};
}//namespace parsers
}//namespace stbx
#endif //SEISMIC_TOOLBOX_PARSERS_PARSER_HPP
| 2,740
|
C++
|
.h
| 71
| 30.028169
| 79
| 0.618976
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,293
|
ArgumentsParser.hpp
|
brightskiesinc_Reverse_Time_Migration/include/stbx/parsers/ArgumentsParser.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of SeismicToolbox.
*
* SeismicToolbox is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SeismicToolbox is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEISMIC_TOOLBOX_PARSERS_ARGUMENTS_PARSER_H
#define SEISMIC_TOOLBOX_PARSERS_ARGUMENTS_PARSER_H
#include <operations/common/Singleton.tpp>
#include <prerequisites/libraries/nlohmann/json.hpp>
namespace stbx {
namespace parsers {
/**
* @brief ArgumentsParser class responsible for parsing argc and argv to the appropriate targets.
*/
class ArgumentsParser {
public:
static void
Parse(std::string &aParameterFile,
std::string &aConfigurationFile,
std::string &aCallbackFile,
std::string &aSystem,
std::string &aWritePath,
int argc, char **argv);
private:
/**
* @brief Private constructor for preventing objects creation.
*/
ArgumentsParser() = default;
static void
PrintHelp();
};
}//namespace parsers
}//namespace stbx
#endif //SEISMIC_TOOLBOX_PARSERS_ARGUMENTS_PARSER_H
| 1,797
|
C++
|
.h
| 47
| 31.276596
| 105
| 0.673176
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,294
|
MemoryManager.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/MemoryManager.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_MODULE_HEADER_HPP
#define BS_BASE_MEMORY_MODULE_HEADER_HPP
#include <bs/base/memory/managers/memory_allocator.h>
#include <bs/base/memory/managers/memory_tracker.h>
#endif //BS_BASE_MEMORY_MODULE_HEADER_HPP
| 994
|
C++
|
.h
| 23
| 41.347826
| 77
| 0.768595
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,295
|
mem_list.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/data-units/mem_list.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_LIST_MEM_H
#define BS_BASE_MEMORY_LIST_MEM_H
#define STRING_LEN 300
#define STACK_SKIP 3
#ifndef MEM_STACK_SIZE
#define MEM_STACK_SIZE 10
#endif
#include <stdlib.h>
namespace bs {
namespace base {
namespace memory {
typedef enum ALLOCATION_TYPE {
MALLOC = 0,
NEW = 1,
_MM_MALLOC = 2,
A_REALLOC = 3,
NEW_ARR = 4,
CALLOC = 5
} allocation_type;
typedef enum DEALLOCATION_TYPE {
FREE = 0,
DELETE = 1,
_MM_FREE = 2,
D_REALLOC = 3,
DELETE_ARR = 4
} deallocation_type;
int matching_calls(allocation_type alc, deallocation_type dealc);
void call_type_to_string(char *str, int type, int allocation);
/**
* Memory Black data.
**/
typedef struct MEM_ELEM {
void *addr;
// Name of the block if assigned by user.
char name[STRING_LEN];
// Details about where it was allocated.
#if (MEM_TRACK >= 1)
char malloc_file_name[STRING_LEN];
char malloc_function_name[STRING_LEN];
int malloc_line;
#endif
// Details about where it was freed.
#if (MEM_TRACK >= 2)
char free_file_name[STRING_LEN];
char free_function_name[STRING_LEN];
int free_line;
#endif
// Stack trace at time of allocation and at time of deallocation.
#if (MEM_TRACK >= 3)
char **malloc_frame;
int malloc_frame_size;
char **free_frame;
int free_frame_size;
#endif
// Size allocated of block.
size_t size;
allocation_type a_call;
deallocation_type d_call;
// Linked list links.
struct MEM_ELEM *next;
struct MEM_ELEM *prev;
} MEM_ELEM;
/* No need for explanation ? a struct to contain the MEMory LIST details */
typedef struct MEM_LIST {
MEM_ELEM *start;
MEM_ELEM *end;
unsigned long long size;
} MEM_LIST;
/**
* Initializes a list to begin using it.
**/
void init_list(MEM_LIST *list);
/**
* Add a block to a list.
**/
void add_block(MEM_LIST *list, MEM_ELEM *elem);
/**
* Get block with that address from the list.
* Return Null if not found.
**/
MEM_ELEM *get_block(MEM_LIST *list, void *addr);
/**
* Removes the block with the assigned address <addr> from the current_blocks
*list and returns a pointer to the block. If no block is found with that
*address, NULL will be returned.
**/
MEM_ELEM *free_block(MEM_LIST *current_blocks, void *addr);
/**
* Deletes a list, with all the blocks in it.
**/
void delete_list(MEM_LIST *list);
/**
* Prints all block in a list.
**/
void print_list(MEM_LIST *list);
/**
* Creats a memory block and puts its allocation details in it. Returns that
*block.
**/
#if (MEM_TRACK == 1 || MEM_TRACK == 2)
MEM_ELEM *create_block(void *addr, size_t size, const char *file,
const char *func, int line, allocation_type acall);
#elif (MEM_TRACK == 3)
MEM_ELEM *create_block(void *addr, size_t size, const char *file,
const char *func, int line, char **stack,
size_t stack_size, allocation_type acall);
#else
MEM_ELEM *create_block(void *addr, size_t size, allocation_type acall);
#endif
/**
* Adds deallocation data to a block.
**/
#if (MEM_TRACK == 2)
void modify_block(MEM_ELEM *elem, const char *file, const char *func, int line,
deallocation_type dcall);
#elif (MEM_TRACK == 3)
void modify_block(MEM_ELEM *elem, const char *file, const char *func, int line,
char **stack, size_t stack_size, deallocation_type dcall);
#else
void modify_block(MEM_ELEM *elem, deallocation_type dcall);
#endif
/**
* Assigns a name to a block.
**/
void name_block(MEM_ELEM *elem, char *name);
/**
* Deletes a block and frees all resources taken by it.
**/
void delete_block(MEM_ELEM *elem);
/**
* Prints a block in a well formatted way.
**/
void print_block(MEM_ELEM *elem);
} //namespace memory
} //namespace base
} //namespace bs
#endif
| 5,366
|
C++
|
.h
| 155
| 26.503226
| 91
| 0.588315
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,296
|
string_list.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/data-units/string_list.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_STRING_LIST_H
#define BS_BASE_MEMORY_STRING_LIST_H
#define MULT_RATE 2
namespace bs {
namespace base {
namespace memory {
typedef struct {
char **strings_list;
int size;
int max_size;
} string_list;
void init_slist(string_list *list, int size);
void add_slist(string_list *list, char *word);
char slist_contains(string_list *list, char *word);
void destroy_slist(string_list *list);
} //namespace memory
} //namespace base
} //namespace bs
#endif //BS_BASE_MEMORY_STRING_LIST_H
| 1,416
|
C++
|
.h
| 37
| 32.648649
| 77
| 0.681519
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,297
|
mem_utils.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/utils/mem_utils.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_MEM_UTILS_H
#define BS_BASE_MEMORY_MEM_UTILS_H
#include <stdlib.h>
namespace bs {
namespace base {
namespace memory {
#define MAX_MSG_LEN 1000
/**
* Extracts the various information from a trace line and returns them.
**/
void extract_address(char *trace, char *file, char *function, char *offset,
char *address);
/**
* Returns the starting address of the .text section in memory.
**/
long int get_start_address(void);
/**
* Processes the trace line to make it more beautiful.
**/
void process_trace_line(char *traceline);
/**
* Transforms a stack trace to contain a line number.
**/
void get_stack_trace_line(char *line, char *trace);
/**
* Given the required depth of the stack trace, it will return an array of
*strings of a size stored in actual_size variable which at maximum is depth
*+ 2.
* + 2 because it assumes depth wanted is given without taking into account the
*call of the function and its internal calls. The pointer it returns should be
*freed to prevent memory leaking.
**/
char **get_stack_trace(int depth, size_t *actual_size);
/**
* Takes a processed stack trace that got transformed to contain line number and
*decrements that line number.
**/
void decrement_line(char *line);
/**
* Get Trace line with the given offset in the stack trace.
**/
void get_trace_line(int offset, char *trace);
/**
* Extracts different info from the trace line.
**/
void extract_info(char *filename, char *function, int *line, char *trace,
char decr);
/**
* Gets the pure name of the trace.
**/
void filter_file_name(char *filtered_name, char *name);
} //namespace memory
} //namespace base
} //namespace bs
#endif
| 2,634
|
C++
|
.h
| 73
| 31.643836
| 87
| 0.690102
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,298
|
logger.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/utils/logger.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_LOGGER_H
#define BS_BASE_MEMORY_LOGGER_H
namespace bs {
namespace base {
namespace memory {
/**
* Initalize Logger options (Should only be called once at the start):
* - console_enable : if false(0) disables output on console. Otherwise, will
*output on console.
* - file_enable : if false(0) disables output on the file named file_name.
*Otherwise, will output on the file.
* - file_name : The name of the file to write to. Will overwrite the file.
*Won't matter if file_enable is false.
**/
void init_logger(char console_enable, char file_enable, char *file_name);
/*
* - Prints the msg string to the valid streams.
*/
void log_msg(char *msg);
/*
* Closes the logger and releases all taken resources.
*/
void close_logger(void);
/*
* Flushs output streams
*/
void log_flush(void);
} //namespace memory
} //namespace base
} //namespace bs
#endif
| 1,725
|
C++
|
.h
| 49
| 31.938776
| 85
| 0.714029
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,299
|
memory_tracker.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/managers/memory_tracker.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_MEMORY_TRACKER_H
#define BS_BASE_MEMORY_MEMORY_TRACKER_H
namespace bs {
namespace base {
namespace memory {
/**
* Not memory tracking, then not compiling !.
**/
#ifdef MEM_TRACK
#include <stdlib.h>
#define malloc(size) omalloc(size, __FILE__, __LINE__, __FUNCTION__)
#define free(ptr) ofree(ptr, __FILE__, __LINE__, __FUNCTION__)
#ifndef MEM_C_ONLY
void *operator new(size_t size);
void *operator new[](size_t size);
void operator delete(void *ptr);
void operator delete[](void *ptr);
#endif
#define _mm_malloc(size, align) \
omm_malloc(size, align, __FILE__, __LINE__, __FUNCTION__)
#define _mm_free(ptr) omm_free(ptr, __FILE__, __LINE__, __FUNCTION__)
#define realloc(ptr, new_size) \
orealloc(ptr, new_size, __FILE__, __LINE__, __FUNCTION__)
#define calloc(num, size) ocalloc(num, size, __FILE__, __LINE__, __FUNCTION__)
/* Initializer function that will get executed before main */
void memory_track_startup(void) __attribute__((constructor));
/* Clean up function that will get executed after main */
void memory_track_cleanup(void) __attribute__((destructor));
/**
* Gives a name to a pointer to keep track of it in the final output.
**/
void name_ptr(void *ptr, char *name);
// Signal handler, will catch signals like segmentation fault and print the
// stack trace of it.
void seg_handler(int signum);
#ifdef __cplusplus
extern "C" {
#endif
// override malloc
extern void *omalloc(size_t size, const char *file, int l, const char *func);
// override realloc
extern void *orealloc(void *ptr, size_t new_size, const char *file, int l,
const char *func);
// override calloc
extern void *ocalloc(size_t num, size_t size, const char *file, int l,
const char *func);
// override free
extern void ofree(void *ptr, const char *file, int l, const char *func);
#ifndef MEM_NO_INTEL
// override _mm_alloc
extern void *omm_malloc(size_t size, size_t align, char const *file, int l,
char const *func);
// override mem_free
extern void omm_free(void *ptr, char const *file, int l, char const *func);
#endif
#ifdef __cplusplus
}
#endif
/**
* Prints done data at time of checkpoint.
**/
void mem_checkpoint(char *name);
/**
* Registers c++ file to track.
**/
void register_cpp_file(char *name);
#else
/**
* Empty functions to prevent code dependencies of outer programs.s
**/
inline void name_ptr(void *ptr, char *name) { ; }
inline void mem_checkpoint(char *name) { ; }
inline void register_cpp_file(char *name) { ; }
#endif
} //namespace memory
} //namespace base
} //namespace bs
#endif //BS_BASE_MEMORY_MEMORY_TRACKER_H
| 4,042
|
C++
|
.h
| 96
| 34.1875
| 89
| 0.594388
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,300
|
memory_allocator.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/memory/managers/memory_allocator.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_MEMORY_MEMORY_ALLOCATOR_H
#define BS_BASE_MEMORY_MEMORY_ALLOCATOR_H
#include <string>
namespace bs {
namespace base {
namespace memory {
/**
* @generalnote
* In malloc and mm__malloc they use as byte_size (size_t )
* which equals unsigned long long void * malloc( size_t size );
*/
/**
* @brief Allocates aligned memory and returns an aligned pointer with the requested
* size.
*
* @param size_of_type
* The size in bytes of a single object that this pointer should point to.
* Normally given by sizeof(type).
*
* @param number_of_elements
* The number of elements that our pointer should contain.
*
* @param name
* A user given name for the pointer for tracking purposes.
*
* @return
* A void aligned pointer with the given size allocated.
*/
void *mem_allocate(unsigned long long size_of_type,
unsigned long long number_of_elements, const std::string &name);
/**
* @brief Allocates aligned memory and returns an aligned pointer with the requested
* size.
*
* @param size_of_type
* The size in bytes of a single object that this pointer should point to.
* Normally given by sizeof(type).
*
* @param number_of_elements
* The number of elements that our pointer should contain.
*
* @param name
* A user given name for the pointer for tracking purposes.
*
* @param half_length_padding
* A padding to be added to the alignment.
*
* @return
* A void aligned pointer with the given size allocated.
*/
void *mem_allocate(unsigned long long size_of_type,
unsigned long long number_of_elements, const std::string &name,
uint half_length_padding);
/**
* @brief Allocates aligned memory and returns an aligned pointer with the requested
* size.
*
* @param size_of_type
* The size in bytes of a single object that this pointer should point to.
* Normally given by sizeof(type).
*
* @param number_of_elements
* The number of elements that our pointer should contain.
*
* @param name
* A user given name for the pointer for tracking purposes.
*
* @param half_length_padding
* A padding to be added to the alignment.
*
* @param masking_allocation_factor
* An offset to differentiate and make sure of different pointer caching.
*
* @return
* A void aligned pointer with the given size allocated.
*/
void *mem_allocate(unsigned long long size_of_type,
unsigned long long number_of_elements, const std::string &name,
uint half_length_padding, uint masking_allocation_factor);
/**
* @brief Frees an aligned memory block.
*
* @param ptr
* The aligned void pointer to be freed.
*/
void mem_free(void *ptr);
} //namespace memory
} //namespace base
} //namespace bs
#endif //BS_BASE_MEMORY_MEMORY_ALLOCATOR_H
| 3,667
|
C++
|
.h
| 108
| 29.990741
| 95
| 0.704142
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,301
|
Logger.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/Logger.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_MODULE_HEADER_HPP
#define BS_BASE_LOGGER_MODULE_HEADER_HPP
/* INTERFACE. */
#include <bs/base/logger/interface/Logger.hpp>
/* CONCRETES. */
#include <bs/base/logger/concrete/ConsoleLogger.hpp>
#include <bs/base/logger/concrete/FileLogger.hpp>
#include <bs/base/logger/concrete/GeneralLogger.hpp>
#include <bs/base/logger/concrete/LoggerChannel.hpp>
#include <bs/base/logger/concrete/LoggerCollection.hpp>
#include <bs/base/logger/concrete/LoggerSystem.hpp>
#endif //BS_BASE_LOGGER_MODULE_HEADER_HPP
| 1,287
|
C++
|
.h
| 30
| 41.2
| 77
| 0.775738
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,302
|
LoggerSystem.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/LoggerSystem.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_LOGGER_SYSTEM_HPP
#define BS_BASE_LOGGER_LOGGER_SYSTEM_HPP
#include <bs/base/logger/concrete/LoggerCollection.hpp>
#include <bs/base/logger/concrete/LoggerChannel.hpp>
#include <bs/base/logger/interface/Logger.hpp>
#include <bs/base/common/Singleton.tpp>
namespace bs {
namespace base {
namespace logger {
class LoggerSystem : public common::Singleton<LoggerSystem> {
public:
friend class Singleton<LoggerSystem>;
/**
* @brief constructor.
*/
LoggerSystem();
/**
* @brief Default destructor.
*/
~LoggerSystem() = default;
/**
* Wrapper for the RegisterLogger function of the Logger collection
* @param aLogger :Logger to be registered
*/
void RegisterLogger(Logger *aLogger);
/**
* @brief Wrapper for the ConfigureLoggers function of the Logger collection
*
* @param[in] aLoggerName
* The string of loggerName
*
* @param[in] aMode
* The WriterMode to select from file, console or both
*
* @param[in] aPattern
* The patterns to select which format will print
*/
void ConfigureLoggers(const std::string &aLoggerName,
WriterMode aMode = FILE_CONSOLE,
Pattern aPattern = DATE_TIME);
/**
* Choose the Info logger channel.
* @return
*/
LoggerChannel &Info();
/**
* Choose the Error logger channel.
* @return
*/
LoggerChannel &Error();
/**
* Choose the Critical logger channel.
* @return
*/
LoggerChannel &Critical();
/**
* Choose the Debug logger channel.
* @return
*/
LoggerChannel &Debug();
private:
///Instance of LoggerCollection Interface
LoggerCollection mpCollection;
///Vector of pointers to the different logger channels
std::vector<LoggerChannel *> mpLoggerChannels;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_LOGGER_SYSTEM_HPP
| 3,483
|
C++
|
.h
| 88
| 26.727273
| 93
| 0.543865
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,303
|
LoggerCollection.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/LoggerCollection.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_LOGGER_COLLECTION_HPP
#define BS_BASE_LOGGER_LOGGER_COLLECTION_HPP
#include <vector>
#include <sstream>
#include <bs/base/logger/interface/Logger.hpp>
namespace bs {
namespace base {
namespace logger {
/**
* @brief The different logger Modes.
*/
class LoggerCollection {
public:
/**
* @brief Default constructor.
*/
LoggerCollection();
/**
* @brief Default destructor.
*/
~LoggerCollection();
/**
* @brief Adding the different loggers to the vector
*
* @param[in] aLogger
* The vector of loggers
*/
void RegisterLogger(Logger *aLogger);
/**
* @brief Handling the logger requirements
*
* @param[in] aLoggerName
* The string of loggerName
*
* @param[in] aMode
* The WriterMode to select from file, console or both
*
* @param[in] aPattern
* The patterns to select which format will print
*/
void ConfigureLoggers(const std::string &aLoggerName,
WriterMode aMode = FILE_CONSOLE,
Pattern aPattern = DATE_TIME);
/**
* Implement the needed operation for logging
* @param aStatement :the statement to be written
* @param aOperation : operation type
*/
void Operate(const std::string &aStatement, Operation aOperation);
private:
/// Vector of pointers to the available loggers
std::vector<Logger *> mpLoggersVector;
/// The logger mode
WriterMode mMode;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_LOGGER_COLLECTION_HPP
| 2,981
|
C++
|
.h
| 77
| 26.506494
| 82
| 0.547718
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,304
|
LoggerChannel.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/LoggerChannel.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_LOGGER_CHANNEL_H
#define BS_BASE_LOGGER_LOGGER_CHANNEL_H
#include <sstream>
#include <bs/base/logger/interface/Logger.hpp>
#include <bs/base/logger/concrete/LoggerCollection.hpp>
namespace bs {
namespace base {
namespace logger {
class LoggerChannel {
public:
/**
* Constructor
* @param mCollection : pointer to the logger collection
* @param mOperation : Operation type
*/
LoggerChannel(LoggerCollection *aCollection, Operation aOperation);
/**
* @brief Default destructor.
*/
~LoggerChannel();
/**
* @brief overload << operator to accept any number and type of elements
*
* @param[in] aValue
* The template variable to hold the data
*
* @return
* Reference to the LoggerChannel class
*/
template<typename T>
LoggerChannel &operator<<(const T &aValue) {
mStringStream << aValue;
std::string message = mStringStream.str();
const char *cstr = message.c_str();
if (cstr[message.length() - 1] == '\n') {
message.erase(message.size() - 1);
this->mpCollection->Operate(message, this->mOperationType);
mStringStream.str("");
}
return *this;
}
private:
/// The string stream that holds the input data
std::stringstream mStringStream;
///The Operation type
Operation mOperationType;
///Pointer to the LoggerCollection Interface
LoggerCollection *mpCollection;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_LOGGER_CHANNEL_H
| 2,872
|
C++
|
.h
| 71
| 28.859155
| 88
| 0.569484
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,305
|
FileLogger.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/FileLogger.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_FILE_LOGGER_HPP
#define BS_BASE_LOGGER_FILE_LOGGER_HPP
#include <fstream>
#include <bs/base/logger/interface/Logger.hpp>
#include <bs/base/logger/concrete/GeneralLogger.hpp>
namespace bs {
namespace base {
namespace logger {
class FileLogger : public GeneralLogger {
public:
explicit FileLogger(const std::string &aFilePath);
~FileLogger() override;
void
Configure(std::string aLoggerName) override;
WriterMode
GetType() override;
void
Operate(std::string aStatement, Operation aOperation) override;
private:
static int
HandleFilePath(const std::string &aFilePath);
private:
/// The filepath
std::string mFilePath;
/// The statement
std::string mStatement;
/// The file stream
std::ofstream mFileStream;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_FILE_LOGGER_HPP
| 1,941
|
C++
|
.h
| 51
| 29.803922
| 79
| 0.640916
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,306
|
ConsoleLogger.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/ConsoleLogger.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_CONSOLE_LOGGER_H
#define BS_BASE_LOGGER_CONSOLE_LOGGER_H
#include <bs/base/logger/interface/Logger.hpp>
#include <bs/base/logger/concrete/GeneralLogger.hpp>
namespace bs {
namespace base {
namespace logger {
class ConsoleLogger : public GeneralLogger {
public:
ConsoleLogger();
~ConsoleLogger() override;
void
Configure(std::string aLoggerName) override;
WriterMode
GetType() override;
void
Operate(std::string aStatement, Operation aOperation) override;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_CONSOLE_LOGGER_H
| 1,538
|
C++
|
.h
| 40
| 32.075
| 79
| 0.682124
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,307
|
GeneralLogger.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/concrete/GeneralLogger.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_GENERAL_LOGGER_HPP
#define BS_BASE_LOGGER_GENERAL_LOGGER_HPP
#ifdef USING_SPDLOG
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/logger.h>
#endif
#include <bs/base/logger/interface/Logger.hpp>
namespace bs {
namespace base {
namespace logger {
class GeneralLogger : public Logger {
public:
void SetPattern(Pattern aPattern) override {
#ifdef USING_SPDLOG
if (aPattern == Pattern::DATE_TIME_THREAD) {
this->mpLogger->set_pattern("[%Y-%m-%d %H:%M:%S.%e][%n][thread %t][%l] %v");
} else if (aPattern == Pattern::DATE_TIME) {
this->mpLogger->set_pattern("[%Y-%m-%d %H:%M:%S.%e][%n][%l] %v");
} else if (aPattern == Pattern::TIME) {
this->mpLogger->set_pattern("[%H:%M:%S.%e][%n] %v");
} else if (aPattern == Pattern::THREAD) {
this->mpLogger->set_pattern("[thread %t][%n] %v");
}
#endif
}
protected:
#ifdef USING_SPDLOG
/// The logger pointer.
std::shared_ptr<spdlog::logger> mpLogger;
#endif
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_GENERAL_LOGGER_HPP
| 2,126
|
C++
|
.h
| 53
| 32.339623
| 100
| 0.612215
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,308
|
Logger.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/logger/interface/Logger.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_LOGGER_LOGGER_HPP
#define BS_BASE_LOGGER_LOGGER_HPP
#include <string>
#ifdef USING_SPDLOG
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/logger.h>
#endif
namespace bs {
namespace base {
namespace logger {
/**
* @brief The different logger Modes.
*/
enum WriterMode {
FILE_MODE, CONSOLE_MODE, FILE_CONSOLE
};
/**
* @brief The different logger format
*/
enum Pattern {
TIME,
DATE_TIME,
THREAD,
DATE_TIME_THREAD
};
/**
* @brief The different operations type
*/
enum Operation {
INFO,
ERROR,
CRITICAL,
DEBUG
};
/**
* @brief Callback interface to be implemented by loggers
*/
class Logger {
public:
/**
* @brief Default constructor.
*/
Logger() = default;
/**
* @brief Default destructor.
*/
virtual ~Logger() = default;
/**
* @brief
* Configure the type of logger -console or file-.
*
* @param[in] aLoggerName
*
*/
virtual void Configure(std::string aLoggerName) = 0;
/**
* @brief
* Select the format of the message
*
* @param[in] aPattern
* The pattern to be display
*/
virtual void SetPattern(Pattern aPattern) = 0;
/**
* @brief
* Detect the type of current logger
*
* @return
* The WRITER_MODE
*/
virtual WriterMode GetType() = 0;
/**
* Implement the needed operation for logging
* @param aStatement :the statement to be written
* @param aOperation : operation type
*/
virtual void Operate(std::string aStatement, Operation aOperation) = 0;
};
} //namespace logger
} //namespace base
} //namespace bs
#endif //BS_BASE_LOGGER_LOGGER_HPP
| 3,301
|
C++
|
.h
| 100
| 21.04
| 87
| 0.502042
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,309
|
ExitCodes.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/common/ExitCodes.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_COMMON_EXIT_CODES_HPP
#define BS_BASE_COMMON_EXIT_CODES_HPP
namespace bs {
namespace base {
namespace common {
#define BS_BASE_RC_FAILURE 0 /* Failure exit code. */
#define BS_BASE_RC_SUCCESS 1 /* Success exit code. */
#define BS_BASE_RC_ABORTED 2 /* Abortion exit code. */
} // namespace common
} //namespace base
} //namespace bs
#endif //BS_BASE_COMMON_EXIT_CODES_HPP
| 1,213
|
C++
|
.h
| 30
| 37.9
| 77
| 0.713922
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,310
|
assertions.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/common/assertions.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_COMMON_ASSERTIONS_TPP
#define BS_BASE_COMMON_ASSERTIONS_TPP
#include <type_traits>
namespace bs {
namespace base {
namespace common {
#define ASSERT_IS_POD(ARG) std::is_pod<ARG>::value /* Assert that argument refers to a POD. */
#define ASSERT_IS_STR(ARG) std::is_base_of<std::string, ARG>::value /* Assert that argument is a string . */
#define ASSERT_T_TEMPLATE(ARG) \
static_assert(ASSERT_IS_POD(ARG) || ASSERT_IS_STR(ARG), "T type is not compatible")
} // namespace common
} //namespace base
} //namespace bs
#endif //BS_BASE_COMMON_ASSERTIONS_TPP
| 1,393
|
C++
|
.h
| 32
| 41.03125
| 119
| 0.71935
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,311
|
Definitions.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/common/Definitions.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_COMMON_DEFINITIONS_HPP
#define BS_BASE_COMMON_DEFINITIONS_HPP
namespace bs {
namespace base {
namespace common {
#define BS_BASE_DEF_BRIGHTSKIES_COPY_WRITES "Written by Brightskies INC." /* Copyrights. */
} // namespace common
} //namespace base
} //namespace bs
#endif //BS_BASE_COMMON_DEFINITIONS_HPP
| 1,115
|
C++
|
.h
| 28
| 37.178571
| 97
| 0.743068
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,312
|
Common.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/common/Common.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_COMMON_HPP
#define BS_BASE_COMMON_HPP
#include <bs/base/configurations/Configurations.hpp>
#include <bs/base/common/Definitions.hpp>
#include <bs/base/common/ExitCodes.hpp>
#include <bs/base/common/ExitCodes.hpp>
#endif //BS_BASE_COMMON_HPP
| 1,021
|
C++
|
.h
| 25
| 39.04
| 77
| 0.768379
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,313
|
Configurations.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/configurations/Configurations.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_CONFIGURATIONS_MODULE_HEADER_HPP
#define BS_BASE_CONFIGURATIONS_MODULE_HEADER_HPP
/* MAPS. */
#include <bs/base/configurations/concrete/JSONConfigurationMap.hpp>
/* INTERFACES. */
#include <bs/base/configurations/interface/Configurable.hpp>
#include <bs/base/configurations/interface/ConfigurationMap.hpp>
#endif //BS_BASE_CONFIGURATIONS_MODULE_HEADER_HPP
| 1,137
|
C++
|
.h
| 26
| 41.923077
| 77
| 0.778681
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,314
|
JSONConfigurationMap.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/configurations/concrete/JSONConfigurationMap.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_CONFIGURATIONS_JSON_CONFIGURATION_MAP_HPP
#define BS_BASE_CONFIGURATIONS_JSON_CONFIGURATION_MAP_HPP
#include <prerequisites/libraries/nlohmann/json.hpp>
#include <bs/base/configurations/interface/ConfigurationMap.hpp>
namespace bs {
namespace base {
namespace configurations {
/**
* @brief
* A JSON implementation of the configuration map interface.
*
* @tparam
* The primitive type used by the optimizer.
*/
class JSONConfigurationMap : public ConfigurationMap {
public:
/**
* @brief Copy constructor from a nlohmann::json to be able to
* handle getting a JSON directly.
*
* @param[in] aJson
* The json given as task information.
*/
explicit JSONConfigurationMap(nlohmann::json aJson);
/**
* @brief Default destructor.
*/
~JSONConfigurationMap() override = default;
/**
* @brief Getter for the value of the property.
* Same getter for different types of values.
* The type is deduced from the aDefaultValue parameter,
* If the key combination doesn't exist or has a null value,
* the given default value is returned.
*
* @param[in] aSectionKey
* The section key.
*
* @param[in] aPropertyKey
* The property key.
*
* @param[in] aDefaultValue
* The default value used if key doesn't not exist or is a null object.
*
* @return
* value stored under this key, or the default value.
*/
float
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
float aDefaultValue) override;
uint GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
int aDefaultValue) override;
double
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
double aDefaultValue) override;
std::string
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
std::string aDefaultValue) override;
bool
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
bool aDefaultValue) override;
void
WriteValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
std::string aValue) override;
/**
* @brief Check if a section entry exists in the object.
*
* @param[in] aSectionKey
* The section key to check.
*
* @return True if the section exists.
*/
bool
Contains(const std::string &aSectionKey) override;
/**
* @brief Check if a property entry exists in a specific section.
*
* @param[in] aSectionKey
* The section key to check.
*
* @param[in] aPropertyKey
* The property key to check
*
* @return True if the property in that section exists.
*/
bool
Contains(const std::string &aSectionKey,
const std::string &aPropertyKey) override;
size_t
Size();
/**
* @brief Check if map contains the given key
* @param[in] aSectionKey
* @return
*/
bool
HasKey(const std::string &aSectionKey) override;
std::string
GetValue(const std::string &aPropertyKey,
const std::string &aDefaultValue) override;
std::string
ToString() override;
std::string GetKeyValue(const std::string &aPropertyKey,
const std::string &aDefaultValue) override;
/**
* @brief
* This function retrieves the submaps residing in an array in
* the configuration map.
*
* @param
* aSectionKey
*
* @return
* Submaps identified by provided key.
*/
std::vector<bs::base::configurations::ConfigurationMap *>
GetConfigurationArray(std::string &aPropertyKey,
std::string &aSectionKey) override;
/**
* @brief
* This function retrieves the submaps residing in an array in
* the configuration map.
*
* @param
* aPropertyKey, aSectionKey
*
* @return
* Submaps identified by provided keys.
*/
std::vector<bs::base::configurations::ConfigurationMap *>
GetConfigurationArray(std::string &aSectionKey) override;
private:
/// The json object used internally.
nlohmann::json mJson;
};
} //namespace configurations
} //namespace base
} //namespace bs
#endif //BS_BASE_CONFIGURATIONS_JSON_CONFIGURATION_MAP_HPP
| 6,898
|
C++
|
.h
| 163
| 26.429448
| 87
| 0.505814
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,315
|
ConfigurationMap.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/configurations/interface/ConfigurationMap.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_CONFIGURATIONS_CONFIGURATION_MAP_HPP
#define BS_BASE_CONFIGURATIONS_CONFIGURATION_MAP_HPP
#include <string>
#include <sstream>
#include <vector>
namespace bs {
namespace base {
namespace configurations {
/**
* @brief A configuration map containing a subset of properties.
* It is organized as subsections, with each subsection containing a list of properties.
*/
class ConfigurationMap {
public:
/**
* @brief Default constructor.
*/
ConfigurationMap() = default;
/**
* @brief Default destructor.
*/
virtual ~ConfigurationMap() = default;
/**
* @brief Getter for the value of the property.
* it is up to the user to give the correct type for the conversion.
* If the key combination doesn't exist or has a null value,
* the given default value is returned.
*
* @param[in] aSectionKey
* The section key.
*
* @param[in] aPropertyKey
* The property key.
*
* @param[in] aDefaultValue
* The default value used if key doesn't not exist or is a null object.
*
* @return
* T stored under this key, or the default value.
*/
virtual float
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
float aDefaultValue) = 0;
virtual uint
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
int aDefaultValue) = 0;
virtual double
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
double aDefaultValue) = 0;
virtual std::string
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
std::string aDefaultValue) = 0;
virtual bool
GetValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
bool aDefaultValue) = 0;
virtual void
WriteValue(const std::string &aSectionKey,
const std::string &aPropertyKey,
std::string aValue) = 0;
virtual std::string
GetValue(const std::string &aPropertyKey,
const std::string &aDefaultValue) = 0;
virtual std::string
GetKeyValue(const std::string &aPropertyKey,
const std::string &aDefaultValue) = 0;
/**
* @brief Check if a section entry exists in the object.
*
* @param[in] aSectionKey
* The section key to check.
*
* @return True if the section exists.
*/
virtual bool
Contains(const std::string &aSectionKey) = 0;
/**
* @brief Check if map contains the given key
* @param[in] aSectionKey
* @return
*/
virtual bool
HasKey(const std::string &aSectionKey) = 0;
/**
* @brief Check if a property entry exists in a specific section.
*
* @param[in] aSectionKey
* The section key to check.
*
* @param[in] aPropertyKey
* The property key to check
*
* @return True if the property in that section exists.
*/
virtual bool
Contains(const std::string &aSectionKey,
const std::string &aPropertyKey) = 0;
/**
* @brief
* Transform the configuration map into a readable string.
* This string is normally a formatted JSON representation.
*
* @return
* A string representation of the configuration map.
*/
virtual std::string
ToString() = 0;
/**
* @brief
* This function retrieves the submaps residing in an array in
* the configuration map.
*
* @param
* aSectionKey
*
* @return
* Submaps identified by provided key.
*/
virtual std::vector<bs::base::configurations::ConfigurationMap *>
GetConfigurationArray(std::string &aSectionKey) = 0;
/**
* @brief
* This function retrieves the submaps residing in an array in
* the configuration map.
*
* @param
* aPropertyKey, aSectionKey
*
* @return
* Submaps identified by provided keys.
*/
virtual std::vector<bs::base::configurations::ConfigurationMap *>
GetConfigurationArray(std::string &aPropertyKey,
std::string &aSectionKey) = 0;
};
} //namespace configurations
} //namespace base
} //namespace bs
#endif //BS_BASE_CONFIGURATIONS_CONFIGURATION_MAP_HPP
| 6,722
|
C++
|
.h
| 161
| 26.055901
| 100
| 0.498624
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,316
|
Configurable.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/configurations/interface/Configurable.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_CONFIGURATIONS_CONFIGURABLE_HPP
#define BS_BASE_CONFIGURATIONS_CONFIGURABLE_HPP
#include <bs/base/configurations/interface/ConfigurationMap.hpp>
namespace bs {
namespace base {
namespace configurations {
/**
* @brief Interface for any component that can be configured in the system.
*/
class Configurable {
public:
/**
* @brief Default destructor.
*/
virtual ~Configurable() = default;
/**
* @brief
* Acquires the component configuration from a given configuration map.
*
* @param[in] apConfigurationMap
* The configuration map to be used.
*/
virtual void AcquireConfiguration() = 0;
};
} //namespace configurations
} //namespace base
} //namespace bs
#endif //BS_BASE_CONFIGURATIONS_CONFIGURABLE_HPP
| 1,781
|
C++
|
.h
| 46
| 30.76087
| 87
| 0.642197
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,317
|
BSBase.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/api/cpp/BSBase.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_API_CPP_BASE_HPP
#define BS_BASE_API_CPP_BASE_HPP
/* CONFIGURATIONS MODULE. */
#include <bs/base/configurations/Configurations.hpp>
/* LOGGER MODULE. */
#include <bs/base/logger/Logger.hpp>
/* MEMORY MANAGER MODULE. */
#include <bs/base/memory/MemoryManager.hpp>
/* BACKEND MODULE. */
#include <bs/base/backend/Backend.hpp>
#include <bs/base/backend/Technology.hpp>
/* COMMON MODULE. */
#include <bs/base/common/Common.hpp>
/* EXCEPTIONS MODULE. */
#include <bs/base/exceptions/Exceptions.hpp>
#endif //BS_BASE_API_CPP_BASE_HPP
| 1,313
|
C++
|
.h
| 34
| 36.882353
| 77
| 0.756884
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,318
|
base.h
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/api/c/base.h
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_API_C_BASE_H
#define BS_BASE_API_C_BASE_H
/* CONFIGURATIONS. */
#endif //BS_BASE_API_C_BASE_H
| 874
|
C++
|
.h
| 22
| 37.818182
| 77
| 0.751472
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,319
|
Backend.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/backend/Backend.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_BACKENDS_BACKEND_HPP
#define BS_BASE_BACKENDS_BACKEND_HPP
#include <unordered_map>
#include <vector>
#include <bs/base/common/Singleton.tpp>
#include <bs/base/backend/Technology.hpp>
namespace bs {
namespace base {
namespace backend {
#ifdef USING_DPCPP
/**
* @brief
* The algorithm in effect to be used.
*/
enum class SYCL_ALGORITHM {
CPU, GPU, GPU_SHARED, GPU_SEMI_SHARED
};
#endif
class Backend : public common::Singleton<Backend> {
public:
friend class Singleton<Backend>;
public:
/**
* @brief
* Default constructor
*/
Backend();
/**
* @brief
* Default destructor
*/
~Backend();
/**
* @brief
* Creates CUDA kernel launch configuration arguments
* @param[in] aDomainDims
* Dimensions of the domain to be mapped to the grid
* @param[in] aBlockDims
* Dimensions of the thread computation thread block
* @param[in] aSharedMemoryBytes
* Size of the shared memory associated with the kernel
* launch (in bytes)
* @param[in] aExecutorId
* Index of the stream associated with the kernel launch
* @return
* Returns a pointer to the kernel launch configuration arguments
* (Pointer of type KernelConfiguration)
*/
KernelConfiguration
CreateKernelConfiguration(std::vector<uint> aDomainDims,
std::vector<uint> aBlockDims,
size_t aSharedMemoryBytes = 0,
uint aExecutorId = 0);
/**
* @brief
* CUDA error handling function
* @throw TechnologyException
* Check cudaError_t for success, throws exception otherwise
*/
void
ErrorCheck(void *aResult, char *aFile, int aLine);
/**
* @return Executor index in the executor pool map
*/
uint
CreateExecutor();
/**
* @brief
* Get the executor (CUDA stream, OneAPI queue, etc.)
* @param aExecutorID
* unsigned int representing the executor inside in the pool table
* @return executor object
*/
PoolType
GetExecutor(uint aExecutorID);
/**
* @brief Synchronization barrier across the device used
*/
void *
Sync();
#ifdef USING_DPCPP
/**
* @brief
* Get the Device queue in use for the DPC++ computations.
*
* @return
* A pointer to the Device queue in use.
*/
inline cl::sycl::queue *
GetDeviceQueue() { return this->mDeviceQueue; }
/**
* @brief
* Setter for the Device queue being in use.
*
* @param[in] aDeviceQueue
*/
void
SetDeviceQueue(cl::sycl::queue *aDeviceQueue);
/**
* @brief
* Get the algorithm to be used in dpc++ computations.
*
* @return
* The algorithm to be used in all dpc++ computations.
*/
inline SYCL_ALGORITHM
GetAlgorithm() { return this->mOneAPIAlgorithm;}
/**
* @brief
* Setter for the algorithm to be used.
*
* @param[in] aOneAPIAlgorithm
* The algorithm to be used.
*/
void
SetAlgorithm(SYCL_ALGORITHM aOneAPIAlgorithm);
/**
* @brief
* Gets the recommended workgroup number.
*/
inline size_t
GetWorkgroupNumber() const { return this->mWorkgroupNumber; }
/**
* @brief
* Gets the recommended workgroup size.
*/
inline size_t
GetWorkgroupSize() const { return this->mWorkgroupSize; }
#endif
private:
std::unordered_map<uint, PoolType> mExecutorPool;
#ifdef USING_DPCPP
/// The Device queue.
cl::sycl::queue *mDeviceQueue;
/// The DPC++ underlying algorithm being used.
SYCL_ALGORITHM mOneAPIAlgorithm;
/// number of available workgroups for nd_range kernels
size_t mWorkgroupNumber;
/// size of workgroup for nd_range kernels
size_t mWorkgroupSize;
#endif
};
} // namespace backend
} //namespace base
} //namespace bs
#endif //BS_BASE_BACKENDS_BACKEND_HPP
| 6,264
|
C++
|
.h
| 164
| 23.786585
| 82
| 0.497696
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,320
|
Technology.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/backend/Technology.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_BACKENDS_TECHNOLOGY_HPP
#define BS_BASE_BACKENDS_TECHNOLOGY_HPP
#include <exception>
#include <string>
#ifdef USING_DPCPP
#include <CL/sycl.hpp>
#include <dpc_common.hpp>
#endif
namespace bs {
namespace base {
namespace backend {
#ifdef USING_DPCPP
typedef sycl::queue PoolType;
#else
typedef int PoolType;
#endif
struct KernelConfiguration {
/// Dimensions of the gpu grid in blocks (x, y, z)
#ifdef USING_DPCPP
sycl::range<3> mGridDimensions{1, 1, 1};
/// Dimensions of a single gpu computation block in threads (x, y, z)
sycl::range<3> mBlockDimensions{1, 1, 1};
#endif
size_t mSharedMemory;
PoolType mExecutor;
KernelConfiguration() {};
};
} // namespace backend
} //namespace base
} //namespace bs
#endif //BS_BASE_BACKENDS_TECHNOLOGY_HPP
| 1,718
|
C++
|
.h
| 49
| 29.734694
| 85
| 0.680941
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
1,541,321
|
Exceptions.hpp
|
brightskiesinc_Reverse_Time_Migration/libs/BSBase/include/bs/base/exceptions/Exceptions.hpp
|
/**
* Copyright (C) 2021 by Brightskies inc
*
* This file is part of BS Base Package.
*
* BS Base Package is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BS Base Package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BS_BASE_EXCEPTIONS_MODULE_HEADER_HPP
#define BS_BASE_EXCEPTIONS_MODULE_HEADER_HPP
/*
* Exceptions interface.
*/
#include <bs/base/exceptions/interface/BaseException.hpp>
/*
* Concrete exceptions.
*/
#include <bs/base/exceptions/concrete/AxisException.hpp>
#include <bs/base/exceptions/concrete/DeviceNoSpaceException.hpp>
#include <bs/base/exceptions/concrete/DeviceNotFoundException.hpp>
#include <bs/base/exceptions/concrete/DirectionException.hpp>
#include <bs/base/exceptions/concrete/FileNotFoundException.hpp>
#include <bs/base/exceptions/concrete/IllogicalException.hpp>
#include <bs/base/exceptions/concrete/IndexOutOfBoundsException.hpp>
#include <bs/base/exceptions/concrete/NoKeyFoundException.hpp>
#include <bs/base/exceptions/concrete/InvalidKeyValueException.hpp>
#include <bs/base/exceptions/concrete/NotImplementedException.hpp>
#include <bs/base/exceptions/concrete/NullPointerException.hpp>
#include <bs/base/exceptions/concrete/UndefinedException.hpp>
#include <bs/base/exceptions/concrete/UnsupportedFeatureException.hpp>
#endif //BS_BASE_EXCEPTIONS_MODULE_HEADER_HPP
| 1,867
|
C++
|
.h
| 41
| 43.878049
| 77
| 0.807692
|
brightskiesinc/Reverse_Time_Migration
| 36
| 6
| 0
|
LGPL-3.0
|
9/20/2024, 10:45:17 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.