group float timings (to easily disable, they are going away)

This commit is contained in:
Ryan Oldenburg 2021-02-09 23:32:13 -06:00
parent d9fcf71f43
commit 59b186b535
2 changed files with 138 additions and 142 deletions

View file

@ -153,7 +153,7 @@ when defined(amd64) and not defined(pixieNoSimd):
type BlenderSimd* = proc(blackdrop, source: M128i): M128i
proc blendNormalPremultipliedSimd*(backdrop, source: M128i): M128i =
proc blendNormalSimd*(backdrop, source: M128i): M128i =
let
alphaMask = mm_set1_epi32(cast[int32](0xff000000))
oddMask = mm_set1_epi16(cast[int16](0xff00))
@ -187,7 +187,7 @@ when defined(amd64) and not defined(pixieNoSimd):
proc blenderSimd*(blendMode: BlendMode): BlenderSimd =
case blendMode:
of bmNormal: blendNormalPremultipliedSimd
of bmNormal: blendNormalSimd
of bmOverwrite: blendOverwriteSimd
else:
raise newException(PixieError, "No SIMD blender for " & $blendMode)

View file

@ -18,20 +18,144 @@ timeIt "blendNormal":
reset()
timeIt "blendNormalFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendNormalFloats(
backdrop.data[i].color, source.data[i].color
).rgba
reset()
timeIt "blendDarken":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendDarken(backdrop.data[i], source.data[i])
reset()
timeIt "blendMultiply":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
reset()
timeIt "blendLinearBurn":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
reset()
timeIt "blendColorBurn":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorBurn(backdrop.data[i], source.data[i])
reset()
timeIt "blendLighten":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLighten(backdrop.data[i], source.data[i])
reset()
timeIt "blendScreen":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
reset()
timeIt "blendLinearDodge":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
reset()
timeIt "blendColorDodge":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorDodge(backdrop.data[i], source.data[i])
reset()
timeIt "blendOverlay":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendOverlay(backdrop.data[i], source.data[i])
reset()
timeIt "blendSoftLight":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSoftLight(backdrop.data[i], source.data[i])
reset()
timeIt "blendHardLight":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHardLight(backdrop.data[i], source.data[i])
reset()
timeIt "blendDifference":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendDifference(backdrop.data[i], source.data[i])
reset()
timeIt "blendExclusion":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExclusion(backdrop.data[i], source.data[i])
reset()
timeIt "blendHue":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHue(backdrop.data[i], source.data[i])
reset()
timeIt "blendSaturation":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSaturation(backdrop.data[i], source.data[i])
reset()
timeIt "blendColor":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColor(backdrop.data[i], source.data[i])
reset()
timeIt "blendLuminosity":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLuminosity(backdrop.data[i], source.data[i])
reset()
timeIt "blendMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendSubtractMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSubtractMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendIntersectMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendExcludeMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
when defined(amd64) and not defined(pixieNoSimd):
import nimsimd/sse2
reset()
timeIt "blendNormal [simd]":
for i in countup(0, backdrop.data.len - 4, 4):
let
b = mm_loadu_si128(backdrop.data[i].addr)
s = mm_loadu_si128(source.data[i].addr)
mm_storeu_si128(backdrop.data[i].addr, blendNormalSimd(b, s))
reset()
timeIt "blendDarkenFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendDarkenFloats(
@ -40,9 +164,11 @@ timeIt "blendDarkenFloats":
reset()
timeIt "blendMultiply":
timeIt "blendNormalFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMultiply(backdrop.data[i], source.data[i])
backdrop.data[i] = blendNormalFloats(
backdrop.data[i].color, source.data[i].color
).rgba
reset()
@ -54,12 +180,6 @@ timeIt "blendMultiplyFloats":
reset()
timeIt "blendLinearBurn":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearBurn(backdrop.data[i], source.data[i])
reset()
timeIt "blendLinearBurnFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearBurnFloats(
@ -68,12 +188,6 @@ timeIt "blendLinearBurnFloats":
reset()
timeIt "blendColorBurn":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorBurn(backdrop.data[i], source.data[i])
reset()
timeIt "blendColorBurnFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorBurnFloats(
@ -82,12 +196,6 @@ timeIt "blendColorBurnFloats":
reset()
timeIt "blendLighten":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLighten(backdrop.data[i], source.data[i])
reset()
timeIt "blendLightenFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLightenFloats(
@ -96,12 +204,6 @@ timeIt "blendLightenFloats":
reset()
timeIt "blendScreen":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendScreen(backdrop.data[i], source.data[i])
reset()
timeIt "blendScreenFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendScreenFloats(
@ -110,12 +212,6 @@ timeIt "blendScreenFloats":
reset()
timeIt "blendLinearDodge":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearDodge(backdrop.data[i], source.data[i])
reset()
timeIt "blendLinearDodgeFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLinearDodgeFloats(
@ -124,12 +220,6 @@ timeIt "blendLinearDodgeFloats":
reset()
timeIt "blendColorDodge":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorDodge(backdrop.data[i], source.data[i])
reset()
timeIt "blendColorDodgeFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorDodgeFloats(
@ -138,12 +228,6 @@ timeIt "blendColorDodgeFloats":
reset()
timeIt "blendOverlay":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendOverlay(backdrop.data[i], source.data[i])
reset()
timeIt "blendOverlayFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendOverlayFloats(
@ -152,12 +236,6 @@ timeIt "blendOverlayFloats":
reset()
timeIt "blendSoftLight":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSoftLight(backdrop.data[i], source.data[i])
reset()
timeIt "blendSoftLightFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSoftLightFloats(
@ -166,12 +244,6 @@ timeIt "blendSoftLightFloats":
reset()
timeIt "blendHardLight":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHardLight(backdrop.data[i], source.data[i])
reset()
timeIt "blendHardLightFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHardLightFloats(
@ -180,12 +252,6 @@ timeIt "blendHardLightFloats":
reset()
timeIt "blendDifference":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendDifference(backdrop.data[i], source.data[i])
reset()
timeIt "blendDifferenceFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendDifferenceFloats(
@ -194,12 +260,6 @@ timeIt "blendDifferenceFloats":
reset()
timeIt "blendExclusion":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExclusion(backdrop.data[i], source.data[i])
reset()
timeIt "blendExclusionFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExclusionFloats(
@ -208,12 +268,6 @@ timeIt "blendExclusionFloats":
reset()
timeIt "blendHue":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHue(backdrop.data[i], source.data[i])
reset()
timeIt "blendHueFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendHueFloats(
@ -222,12 +276,6 @@ timeIt "blendHueFloats":
reset()
timeIt "blendSaturation":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSaturation(backdrop.data[i], source.data[i])
reset()
timeIt "blendSaturationFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSaturationFloats(
@ -236,12 +284,6 @@ timeIt "blendSaturationFloats":
reset()
timeIt "blendColor":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColor(backdrop.data[i], source.data[i])
reset()
timeIt "blendColorFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendColorFloats(
@ -250,12 +292,6 @@ timeIt "blendColorFloats":
reset()
timeIt "blendLuminosity":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLuminosity(backdrop.data[i], source.data[i])
reset()
timeIt "blendLuminosityFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendLuminosityFloats(
@ -264,12 +300,6 @@ timeIt "blendLuminosityFloats":
reset()
timeIt "blendMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendMaskFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendMaskFloats(
@ -278,12 +308,6 @@ timeIt "blendMaskFloats":
reset()
timeIt "blendSubtractMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSubtractMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendSubtractMaskFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendSubtractMaskFloats(
@ -292,12 +316,6 @@ timeIt "blendSubtractMaskFloats":
reset()
timeIt "blendIntersectMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendIntersectMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendIntersectMaskFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendIntersectMaskFloats(
@ -306,30 +324,8 @@ timeIt "blendIntersectMaskFloats":
reset()
timeIt "blendExcludeMask":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExcludeMask(backdrop.data[i], source.data[i])
reset()
timeIt "blendExcludeMaskFloats":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendExcludeMaskFloats(
backdrop.data[i].color, source.data[i].color
).rgba
reset()
timeIt "blendNormalPremultiplied":
for i in 0 ..< backdrop.data.len:
backdrop.data[i] = blendNormalPremultiplied(backdrop.data[i], source.data[i])
when defined(amd64) and not defined(pixieNoSimd):
import nimsimd/sse2
timeIt "blendNormalPremultiplied [simd]":
for i in countup(0, backdrop.data.len - 4, 4):
let
b = mm_loadu_si128(backdrop.data[i].addr)
s = mm_loadu_si128(source.data[i].addr)
mm_storeu_si128(backdrop.data[i].addr, blendNormalPremultiplied(b, s))