Skip to content

Commit 6034df6

Browse files
committed
ComputeMinMax(): speed-up computation in the non-mask case for all non-complex types (but Byte and UInt16 that were already optimized)
timings wih a SSE2 optimized build: - before: testByte(): 0.306 testInt8(): 5.779 testUInt16(): 0.726 testInt16(): 2.519 testUInt32(): 6.933 testInt32(): 7.537 testUInt64(): 8.140 testInt64(): 7.807 testFloat16(): 12.953 testFloat32(): 6.105 testFloat64(): 6.525 - after testByte(): 0.308 testInt8(): 0.440 testUInt16(): 0.710 testInt16(): 0.897 testUInt32(): 1.986 testInt32(): 1.826 testUInt64(): 6.004 testInt64(): 5.641 testFloat16(): 2.120 testFloat32(): 1.811 testFloat64(): 3.571
1 parent 808a093 commit 6034df6

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

gcore/gdalrasterband.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8260,6 +8260,18 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax)
82608260
}
82618261
}
82628262

8263+
if (!bApproxOK &&
8264+
(eDataType == GDT_Int8 || eDataType == GDT_Int16 ||
8265+
eDataType == GDT_UInt32 || eDataType == GDT_Int32 ||
8266+
eDataType == GDT_UInt64 || eDataType == GDT_Int64 ||
8267+
eDataType == GDT_Float16 || eDataType == GDT_Float32 ||
8268+
eDataType == GDT_Float64) &&
8269+
!poMaskBand)
8270+
{
8271+
return ComputeRasterMinMaxLocation(&adfMinMax[0], &adfMinMax[1],
8272+
nullptr, nullptr, nullptr, nullptr);
8273+
}
8274+
82638275
bool bSignedByte = false;
82648276
if (eDataType == GDT_Byte)
82658277
{

perftests/computeminmax.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
tab_ds = {}
99
for dt in (
1010
gdal.GDT_Byte,
11+
gdal.GDT_Int8,
1112
gdal.GDT_UInt16,
1213
gdal.GDT_Int16,
14+
gdal.GDT_UInt32,
15+
gdal.GDT_Int32,
16+
gdal.GDT_UInt64,
17+
gdal.GDT_Int64,
18+
gdal.GDT_Float16,
1319
gdal.GDT_Float32,
1420
gdal.GDT_Float64,
1521
):
@@ -27,6 +33,10 @@ def test(dt):
2733
"testByte(): %.3f"
2834
% timeit.timeit("test(gdal.GDT_Byte)", setup=setup, number=NITERS)
2935
)
36+
print(
37+
"testInt8(): %.3f"
38+
% timeit.timeit("test(gdal.GDT_Int8)", setup=setup, number=NITERS)
39+
)
3040
print(
3141
"testUInt16(): %.3f"
3242
% timeit.timeit("test(gdal.GDT_UInt16)", setup=setup, number=NITERS)
@@ -35,6 +45,26 @@ def test(dt):
3545
"testInt16(): %.3f"
3646
% timeit.timeit("test(gdal.GDT_Int16)", setup=setup, number=NITERS)
3747
)
48+
print(
49+
"testUInt32(): %.3f"
50+
% timeit.timeit("test(gdal.GDT_UInt32)", setup=setup, number=NITERS)
51+
)
52+
print(
53+
"testInt32(): %.3f"
54+
% timeit.timeit("test(gdal.GDT_Int32)", setup=setup, number=NITERS)
55+
)
56+
print(
57+
"testUInt64(): %.3f"
58+
% timeit.timeit("test(gdal.GDT_UInt64)", setup=setup, number=NITERS)
59+
)
60+
print(
61+
"testInt64(): %.3f"
62+
% timeit.timeit("test(gdal.GDT_Int64)", setup=setup, number=NITERS)
63+
)
64+
print(
65+
"testFloat16(): %.3f"
66+
% timeit.timeit("test(gdal.GDT_Float16)", setup=setup, number=NITERS)
67+
)
3868
print(
3969
"testFloat32(): %.3f"
4070
% timeit.timeit("test(gdal.GDT_Float32)", setup=setup, number=NITERS)

0 commit comments

Comments
 (0)