Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: floating-point comparison error on Loong64 #59000

Closed
ihuang77 opened this issue Mar 13, 2023 · 3 comments
Closed

runtime: floating-point comparison error on Loong64 #59000

ihuang77 opened this issue Mar 13, 2023 · 3 comments
Labels
arch-loong64 Issues solely affecting the loongson architecture. compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ihuang77
Copy link

What version of Go are you using (go version)?

$ go version
go version devel go1.21-f5c7416511 Thu Mar 9 22:13:26 2023 +0000 linux/loong64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

What did you do?

package main

import(
        "fmt"
)

func main() {
        var target float64 = 100000.0
        for i := 1; i < 100000000; i++ {
                var fslice []float64
                for j := 0; j < 100; j++ {
                        fslice = append(fslice, 1.124567)
                }
                var sum float64
                for _, f := range fslice {
                        sum += f
                        sum += 0.1 
                        sum += 0.2 
                        sum += 0.3 
                        if sum >= target {
                                fmt.Println("err 1")
                        }
                        if sum >= target {
                                fmt.Println("err 2")
                        }
                        if sum >= target {
                                fmt.Println("err 3")
                        }
                        if sum >= target {
                                if sum < target {
                                        fmt.Println("err 4")
                                }
                        }
                }
        }
}

What did you expect to see?

(i.e. no output)

What did you see instead?

err 3
err 4
err 2
...

(i.e. numbers are unordered)

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 13, 2023
@gopherbot
Copy link

Change https://go.dev/cl/475577 mentions this issue: runtime: save and restore fcc registers in async preempt on loong64

@abner-chenc abner-chenc added the arch-loong64 Issues solely affecting the loongson architecture. label Mar 13, 2023
@cherrymui cherrymui changed the title cmd/internal/obj/loong64, runtime:Fixed a floating-point comparison error runtime: floating-point comparison error on Loong64 Mar 13, 2023
@cherrymui cherrymui added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 13, 2023
@cherrymui cherrymui added this to the Go1.21 milestone Mar 13, 2023
@mknyszek
Copy link
Contributor

CC @golang/loong64

gopherbot pushed a commit that referenced this issue Mar 22, 2023
During the context switch of goroutine scheduling, the value of the
fcc0 register needs to be saved on the stack.

Fixs #59000.

Change-Id: Ie80dbae738f60df6c11a3fe31fc57de817d76afc
Reviewed-on: https://go-review.googlesource.com/c/go/+/475577
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
@xen0n
Copy link
Member

xen0n commented Mar 23, 2023

Commit 48d61a4 had the "Fixes" keyword misspelled, so the issue was not auto-closed.

Manually closing as completed.

@xen0n xen0n closed this as completed Mar 23, 2023
xen0n pushed a commit to xen0n/go that referenced this issue May 1, 2023
During the context switch of goroutine scheduling, the value of the
fcc0 register needs to be saved on the stack.

Fixs golang#59000.

Change-Id: Ie80dbae738f60df6c11a3fe31fc57de817d76afc
Reviewed-on: https://go-review.googlesource.com/c/go/+/475577
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
(cherry picked from commit 48d61a4)
@golang golang locked and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-loong64 Issues solely affecting the loongson architecture. compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants