FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go


Description:
image/jpeg: skip TestDCT on arm hosts

For arm5 machines, without floating point hardware, TestDCT
takes 2 to 3 minutes. Skip the test for all arm hosts.

Please review this at http://codereview.appspot.com/6734045/

Affected files:
M src/pkg/image/jpeg/dct_test.go


Index: src/pkg/image/jpeg/dct_test.go
===================================================================
--- a/src/pkg/image/jpeg/dct_test.go
+++ b/src/pkg/image/jpeg/dct_test.go
@@ -9,6 +9,7 @@
"fmt"
"math"
"math/rand"
+ "runtime"
"testing"
)

@@ -33,6 +34,10 @@
}

func TestDCT(t *testing.T) {
+ if runtime.GOARCH == "arm" {
+ t.Log("DCT test too slow on arm, skipping.")
+ return
+ }
blocks := make([]block, len(testBlocks))
copy(blocks, testBlocks[:])

Search Discussions

  • Rémy Oudompheng at Oct 18, 2012 at 7:04 am
    Can we make the test faster instead?

    Try introducing a global var cosines [16]float64 holding the value of
    cos(kπ/16). and compute the cosines only once for slowIDCT/slowFDCT.

    Rémy.
  • Rémy Oudompheng at Oct 18, 2012 at 7:09 am
    On amd64 It got 6x faster using this diff, I expect a huge improvement on arm.

    diff -r 6b67a925abcc src/pkg/image/jpeg/dct_test.go
    --- a/src/pkg/image/jpeg/dct_test.go Tue Oct 16 07:22:33 2012 +0200
    +++ b/src/pkg/image/jpeg/dct_test.go Thu Oct 18 09:08:50 2012 +0200
    @@ -112,6 +112,14 @@
    return math.Sqrt2
    }

    +var cosines [32]float64 // cosines[k] = cos(π/2 * k/8)
    +
    +func init() {
    + for k := range cosines {
    + cosines[k] = math.Cos(math.Pi * float64(k) / 16)
    + }
    +}
    +
    // slowFDCT performs the 8*8 2-dimensional forward discrete cosine transform:
    //
    // dst[u,v] = (1/8) * Σ_x Σ_y alpha(u) * alpha(v) * src[x,y] *
    @@ -129,8 +137,8 @@
    for y := 0; y < 8; y++ {
    for x := 0; x < 8; x++ {
    sum += alpha(u) * alpha(v) * float64(b[8*y+x]) *
    - math.Cos(math.Pi*float64((2*x+1)*u)/16) *
    - math.Cos(math.Pi*float64((2*y+1)*v)/16)
    + cosines[((2*x+1)*u)%32] *
    + cosines[((2*y+1)*v)%32]
    }
    }
    dst[8*v+u] = sum / 8
    @@ -159,8 +167,8 @@
    for v := 0; v < 8; v++ {
    for u := 0; u < 8; u++ {
    sum += alpha(u) * alpha(v) * float64(b[8*v+u]) *
    - math.Cos(math.Pi*float64((2*x+1)*u)/16) *
    - math.Cos(math.Pi*float64((2*y+1)*v)/16)
    + cosines[((2*x+1)*u)%32] *
    + cosines[((2*y+1)*v)%32]
    }
    }
    dst[8*y+x] = sum / 8
  • Dave Cheney at Oct 18, 2012 at 7:44 am
    Thanks Rémy,

    before; ~ 132seconds on a 2Ghz arm5

    after:

    === RUN TestDCT
    --- PASS: TestDCT (12.05 seconds)
    PASS
    ok image/jpeg 12.073s

    I'm going to abandon this proposal, you should definitely propose your fix.

    On Thu, Oct 18, 2012 at 6:09 PM, Rémy Oudompheng
    wrote:
    On amd64 It got 6x faster using this diff, I expect a huge improvement on arm.

    diff -r 6b67a925abcc src/pkg/image/jpeg/dct_test.go
    --- a/src/pkg/image/jpeg/dct_test.go Tue Oct 16 07:22:33 2012 +0200
    +++ b/src/pkg/image/jpeg/dct_test.go Thu Oct 18 09:08:50 2012 +0200
    @@ -112,6 +112,14 @@
    return math.Sqrt2
    }

    +var cosines [32]float64 // cosines[k] = cos(π/2 * k/8)
    +
    +func init() {
    + for k := range cosines {
    + cosines[k] = math.Cos(math.Pi * float64(k) / 16)
    + }
    +}
    +
    // slowFDCT performs the 8*8 2-dimensional forward discrete cosine transform:
    //
    // dst[u,v] = (1/8) * Σ_x Σ_y alpha(u) * alpha(v) * src[x,y] *
    @@ -129,8 +137,8 @@
    for y := 0; y < 8; y++ {
    for x := 0; x < 8; x++ {
    sum += alpha(u) * alpha(v) * float64(b[8*y+x]) *
    - math.Cos(math.Pi*float64((2*x+1)*u)/16) *
    - math.Cos(math.Pi*float64((2*y+1)*v)/16)
    + cosines[((2*x+1)*u)%32] *
    + cosines[((2*y+1)*v)%32]
    }
    }
    dst[8*v+u] = sum / 8
    @@ -159,8 +167,8 @@
    for v := 0; v < 8; v++ {
    for u := 0; u < 8; u++ {
    sum += alpha(u) * alpha(v) * float64(b[8*v+u]) *
    - math.Cos(math.Pi*float64((2*x+1)*u)/16) *
    - math.Cos(math.Pi*float64((2*y+1)*v)/16)
    + cosines[((2*x+1)*u)%32] *
    + cosines[((2*y+1)*v)%32]
    }
    }
    dst[8*y+x] = sum / 8
  • Dave at Oct 18, 2012 at 8:24 am

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 18, '12 at 5:09a
activeOct 18, '12 at 8:24a
posts5
users2
websitegolang.org

2 users in discussion

Dave: 3 posts Rémy Oudompheng: 2 posts

People

Translate

site design / logo © 2022 Grokbase