Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 625b2860f..463cb15ae
Browse files Browse the repository at this point in the history
463cb15ae Make it easier to turn off SIMD support (#770)
a6f8cc400 determine UTF-8 at compile-time (#768)
586249d49 use lookup tables; remove "strict" processing (#767)
3add73906 Merge branch 'main' of github.com:mdaus/coda-oss
3ea6e1958 remove sys::Ximd (#766)
bfdc4b1ea std::execution::par is slow with GCC ...
d723792a2 Build cleanly with cmake "release" (#765)

git-subtree-dir: externals/coda-oss
git-subtree-split: 463cb15aeb5cf802753d9adfe7bb2520c58a8c06
  • Loading branch information
Dan Smith committed Feb 14, 2024
1 parent e8db357 commit d064b4d
Show file tree
Hide file tree
Showing 18 changed files with 397 additions and 1,112 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
os: [windows-latest]
platform: [x64]
configuration: [Debug] # Debug turns on more compiler warnings
avx: [AVX2, AVX512F]
avx: [AVX512F]
name: ${{ matrix.os }}-${{ matrix.avx }}-msbuild
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
matrix:
os: [ubuntu-latest]
configuration: [Debug, Release]
avx: [AVX2, AVX512F]
avx: [AVX512F]
name: ${{ matrix.os }}-${{ matrix.configuration }}-${{ matrix.avx }}-CMake
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 0 additions & 4 deletions UnitTest/UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\modules\c++\sys\unittests\test_ximd.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\modules\c++\types\unittests\test_complex.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
Expand Down
3 changes: 0 additions & 3 deletions UnitTest/UnitTest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@
<ClCompile Include="..\modules\drivers\highfive\unittests\tests_high_five_base.cpp">
<Filter>hdf5.lite</Filter>
</ClCompile>
<ClCompile Include="..\modules\c++\sys\unittests\test_ximd.cpp">
<Filter>sys</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand Down
5 changes: 0 additions & 5 deletions UnitTest/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <sys/DateTime.h>
#include <sys/Conf.h>
#include <sys/Path.h>
#include <sys/Ximd.h>

namespace sys
{
Expand Down Expand Up @@ -59,8 +58,4 @@ TEST_CLASS(test_path){ public:
#include "sys/unittests/test_path.cpp"
};

TEST_CLASS(test_ximd){ public:
#include "sys/unittests/test_ximd.cpp"
};

}
11 changes: 11 additions & 0 deletions cmake/CodaBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ macro(coda_initialize_build)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Turn on AVX2 by default ... it's from 2013.
# Well, no :-( ... it seems to cause crashes w/older
# compilers on build servers. :-(
set(ENABLE_AVX2 false)
set(ENABLE_AVX512F false)
#if (NOT ENABLE_AVX512F)
# if (NOT DISABLE_AVX2)
# set(ENABLE_AVX2 true)
# endif()
#endif()

# MSVC-specific flags and options.
if (MSVC)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down
9 changes: 6 additions & 3 deletions modules/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ if (MSVC)

elseif (UNIX)
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
add_compile_options(-Werror) # Make all warnings into errors
#add_compile_options(-Werror) # Make all warnings into errors
add_compile_options(-Wall -Wextra -Wpedantic -pedantic-errors -Wunused)

add_compile_options(-Wzero-as-null-pointer-constant)
add_compile_options(-Wsuggest-final-types -Wsuggest-final-methods)
#add_compile_options(-Wsuggest-final-types -Wsuggest-final-methods)
add_compile_options(-Wsuggest-override)
add_compile_options(-Woverloaded-virtual)
add_compile_options(-Warray-bounds)
#add_compile_options(-Warray-bounds)
add_compile_options(-Wduplicated-branches -Wduplicated-cond)
add_compile_options(-Wtrampolines)
add_compile_options(-Wshadow)
Expand All @@ -29,6 +29,9 @@ elseif (UNIX)

add_compile_options(-Wno-double-promotion) # implicit conversion of `float` to `double` is fine

add_compile_options(-Wno-array-bounds) # TODO: fix the code!
add_compile_options(-Wno-maybe-uninitialized) # TODO: fix the code!

# Need a newer compiler than GCC 9
#add_compile_options(-Wnrvo)
endif()
Expand Down
28 changes: 21 additions & 7 deletions modules/c++/avx/unittests/test_m256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,24 @@ TEST_CASE(test_getSIMDInstructionSet)
{
// This is the reverse of getSIMDInstructionSet(): it uses the macros to generate a value.
constexpr auto simdInstructionSet = sys::getSIMDInstructionSet();
#if __AVX512F__
static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX512F, "getSIMDInstructionSet()");
#elif __AVX2__
static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX2, "getSIMDInstructionSet()");
#if CODA_OSS_ENABLE_SIMD
#if __AVX512F__
static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX512F, "getSIMDInstructionSet()");
#elif __AVX2__
static_assert(simdInstructionSet == sys::SIMDInstructionSet::AVX2, "getSIMDInstructionSet()");
#else
static_assert(simdInstructionSet == sys::SIMDInstructionSet::SSE2, "getSIMDInstructionSet()");
#endif
#else
static_assert(simdInstructionSet == sys::SIMDInstructionSet::SSE2, "getSIMDInstructionSet()");
#endif
static_assert(simdInstructionSet == sys::SIMDInstructionSet::Disabled, "getSIMDInstructionSet()");
#endif // CODA_OSS_ENABLE_SIMD

CODA_OSS_disable_warning_push
#if _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif

switch (sys::getSIMDInstructionSet()) // run-time value
switch (sys::getSIMDInstructionSet()) // run-time value (well, not really, but it could be)
{
case sys::SIMDInstructionSet::SSE2:
{
Expand All @@ -86,6 +90,16 @@ TEST_CASE(test_getSIMDInstructionSet)
TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::AVX512F);
break;
}
case sys::SIMDInstructionSet::Disabled:
{
TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::Disabled);
break;
}
case sys::SIMDInstructionSet::Unknown:
{
TEST_ASSERT(simdInstructionSet == sys::SIMDInstructionSet::Unknown);
break;
}
default:
{
TEST_FAIL;
Expand Down
1 change: 0 additions & 1 deletion modules/c++/coda-oss.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@
<ClInclude Include="sys\include\sys\ThreadWin32.h" />
<ClInclude Include="sys\include\sys\TimeStamp.h" />
<ClInclude Include="sys\include\sys\UTCDateTime.h" />
<ClInclude Include="sys\include\sys\Ximd.h" />
<ClInclude Include="tiff\include\tiff\Common.h" />
<ClInclude Include="tiff\include\tiff\FileReader.h" />
<ClInclude Include="tiff\include\tiff\FileWriter.h" />
Expand Down
9 changes: 3 additions & 6 deletions modules/c++/coda-oss.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,6 @@
<ClInclude Include="coda_oss\include\coda_oss\mdspan_.h">
<Filter>coda_oss</Filter>
</ClInclude>
<ClInclude Include="sys\include\sys\Ximd.h">
<Filter>sys</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
Expand Down Expand Up @@ -1445,9 +1442,6 @@
<Filter Include="math.poly">
<UniqueIdentifier>{15f9b62f-d17e-4d84-bc34-de6fd5fbcb33}</UniqueIdentifier>
</Filter>
<Filter Include="polygon">
<UniqueIdentifier>{f2544ccb-0933-44c7-af39-cd986982af3d}</UniqueIdentifier>
</Filter>
<Filter Include="include">
<UniqueIdentifier>{9050a469-23a5-4da0-92b1-a07a8e52e9fc}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -1502,6 +1496,9 @@
<Filter Include="coda_oss">
<UniqueIdentifier>{59f3d9a1-06d3-4779-aef2-cc55223c3017}</UniqueIdentifier>
</Filter>
<Filter Include="polygon">
<UniqueIdentifier>{f2544ccb-0933-44c7-af39-cd986982af3d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="gsl\include\gsl\algorithm">
Expand Down
18 changes: 7 additions & 11 deletions modules/c++/logging/source/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
std::unique_ptr<logging::Logger>
logging::setupLogger(const path& program_,
const std::string& logLevel,
const path& logFile_,
const path& logFile,
const std::string& logFormat,
size_t logCount,
size_t logBytes)
Expand All @@ -44,29 +44,25 @@ logging::setupLogger(const path& program_,
std::unique_ptr<logging::Logger> log(new logging::Logger(program));

// setup logging level
std::string lev = logLevel;
str::upper(lev);
auto lev = str::upper(logLevel);
str::trim(lev);
logging::LogLevel level = (lev.empty()) ? logging::LogLevel::LOG_WARNING :
logging::LogLevel(lev);
const auto level = lev.empty() ? logging::LogLevel::LOG_WARNING : logging::LogLevel(lev);

// setup logging formatter
std::unique_ptr <logging::Formatter> formatter;
const auto logFile = logFile_.string();
const auto file = str::lower(logFile);
const auto file = str::lower(logFile.string());
if (str::endsWith(file, ".xml"))
{
formatter.reset(
new logging::XMLFormatter("", "<Log image=\"" + program + "\">"));
formatter = std::make_unique<logging::XMLFormatter>("", "<Log image=\"" + program + "\">");
}
else
{
formatter.reset(new logging::StandardFormatter(logFormat));
formatter = std::make_unique<logging::StandardFormatter>(logFormat);
}

// setup logging handler
std::unique_ptr<logging::Handler> logHandler;
if (file.empty() || file == "console")
if (file.empty() || (file == "console") || (file == "-"))
logHandler.reset(new logging::StreamHandler());
else
{
Expand Down
9 changes: 7 additions & 2 deletions modules/c++/mt/include/mt/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ inline OutputIt Transform_par(InputIt first1, InputIt last1, OutputIt d_first, U
Transform_par_settings settings = Transform_par_settings{})
{
#if CODA_OSS_mt_Algorithm_has_execution
CODA_OSS_mark_symbol_unused(settings);
return std::transform(std::execution::par, first1, last1, d_first, unary_op);
#if __GNUC__
// std::execution::par is dramatically slower w/GCC than using our own ... ???
return Transform_par_(first1, last1, d_first, unary_op, settings); // TODO: std::execution::par
#else
CODA_OSS_mark_symbol_unused(settings);
return std::transform(std::execution::par, first1, last1, d_first, unary_op);
#endif // __GNUC__
#else
return Transform_par_(first1, last1, d_first, unary_op, settings);
#endif // CODA_OSS_mt_Algorithm_has_execution
Expand Down
16 changes: 12 additions & 4 deletions modules/c++/str/include/str/Manip.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,30 @@ inline std::string upper(const std::string& s)

// At this point, you might want to `lower()` and `upper()` for UTF-8 and/or
// Windows-1252. That can be done, but ... our needs are mostly English (99.9%)
// with a very occassional smattering of French (Canada). We've gotten by this
// with a very occassional smattering of (Canadian-) French. We've gotten by this
// long without being able to upper/lower 'ä' and 'Ä' and there's no current
// requirement to do so.
//
// Furthermore, while Windows-1252 is easy as it's a single-byte encoding and
// covers many european languages, the standard is UTF-8.
// Upper/lower-casing in Unicode is quite a bit more complicated as there can be
// covers many european languages, the standard is UTF-8. Changing case
// with Unicode is quite a bit more complicated as there can be
// numerous rules for various languages. For example, in German, the "old
// rules" where that 'ß' was uppercased to "SS"; however, there is now a 'ẞ'.
// And then there are semantics: in German, no word can begin with 'ß' (or 'ẞ')
// making "ßanything" rather non-sensical.
//
// So for now (until there is a real use case), just "define these problems
// away" by not implementing `w1252_lower()`, `utf8_upper()`, etc.
// away" by not exposing `w1252_lower()`, `utf8_upper()`, etc.
/*
// With Windows-1252 encoding, we can convert between 'ä' and 'Ä'.
CODA_OSS_API void w1252_lower(std::string& s);
CODA_OSS_API void w1252_upper(std::string& s);
CODA_OSS_API void lower(str::W1252string& s);
CODA_OSS_API void upper(str::W1252string& s);
// Hooking up UTF-8 for completeness and unit-testing.
// ** THESE ROUTINES ARE SLOW **
// Performance improvements can be made, but nobody needs such right now.
CODA_OSS_API void utf8_lower(std::string& s);
CODA_OSS_API void utf8_upper(std::string& s);
CODA_OSS_API void lower(coda_oss::u8string& s);
Expand All @@ -244,6 +248,10 @@ CODA_OSS_API str::Windows1252_T to_w1252_lower(str::Windows1252_T);

/***********************************************************************************/

// Using std::transform() with ::toupper() is considerably slower than a lookup-table
CODA_OSS_API void ascii_lower(std::string& s);
CODA_OSS_API void ascii_upper(std::string& s);

/*!
* Replaces any characters that are invalid in XML (&, <, >, ', ") with their
* escaped counterparts
Expand Down
Loading

0 comments on commit d064b4d

Please sign in to comment.