Skip to content

Commit 492a7b3

Browse files
committed
GDALDataset::ComputeInterBandCovarianceMatrix(): optimize CPU usage
1 parent 4674ed5 commit 492a7b3

File tree

3 files changed

+452
-226
lines changed

3 files changed

+452
-226
lines changed

autotest/gcore/gdal_stats.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_nodata():
14591459
ds.GetRasterBand(2).WriteRaster(0, 0, 4, 1, b"\x02\x01\xFE\x03")
14601460
ds.GetRasterBand(2).SetNoDataValue(254)
14611461

1462-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1462+
expected_cov_matrix = [[1, 0], [0, 1]]
14631463

14641464
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
14651465
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(
@@ -1476,7 +1476,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_nan_value():
14761476
ds.GetRasterBand(1).WriteRaster(0, 0, 4, 1, struct.pack("f" * 4, 1, 2, 3, math.nan))
14771477
ds.GetRasterBand(2).WriteRaster(0, 0, 4, 1, struct.pack("f" * 4, 2, 1, math.nan, 3))
14781478

1479-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1479+
expected_cov_matrix = [[1, 0], [0, 1]]
14801480

14811481
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
14821482
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(
@@ -1527,7 +1527,7 @@ def test_stats_ComputeInterBandCovarianceMatrix_mask_band():
15271527
ds.GetRasterBand(2).CreateMaskBand(0)
15281528
ds.GetRasterBand(2).GetMaskBand().WriteRaster(0, 0, 4, 1, b"\xFF\xFF\x00\xFF")
15291529

1530-
expected_cov_matrix = [[1, -0.5], [-0.5, 1]]
1530+
expected_cov_matrix = [[1, 0], [0, 1]]
15311531

15321532
cov_matrix = ds.ComputeInterBandCovarianceMatrix()
15331533
assert list(chain.from_iterable(cov_matrix)) == pytest.approx(

gcore/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ add_library(
6464
enviutils.cpp
6565
)
6666

67+
include(CheckCXXCompilerFlag)
68+
check_cxx_compiler_flag(-fopenmp-simd HAVE_OPENMD_SIMD)
69+
if (HAVE_OPENMD_SIMD)
70+
target_compile_definitions(gcore PRIVATE HAVE_OPENMD_SIMD)
71+
target_compile_options(gcore PRIVATE "-fopenmp-simd")
72+
endif()
73+
6774
add_library(gcore_gdal_misc OBJECT gdal_misc.cpp)
6875
gdal_standard_includes(gcore_gdal_misc)
6976
add_dependencies(gcore_gdal_misc generate_gdal_version_h)

0 commit comments

Comments
 (0)