[BUG] Duplicate `ATag` error during sharing recovery with parallel GC
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
The bug is in Data.Array.Accelerate.Trafo.Sharing (Sharing.hs); start at internalError (line 2243) and buildInitialEnvAcc (line 2623). Read sharing recovery near line 3084 and reproduce with given Main.hs via ghc -O1 -threaded -rtsopts -package accelerate then ./repro +RTS -A64k -RTS. Done when 1000 conversions succeed without duplicate ATag errors under parallel GC.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- Accelerate 1.4.0.0
- GHC 9.8.4 / base 4.19.2.0
- Linux x86_64
Reproducing
Main.hs:
module Main where
import Control.Exception (evaluate)
import Control.Monad (forM_, when)
import qualified Data.Array.Accelerate as A
import qualified Data.Array.Accelerate.Trafo.Sharing as Sharing
import GHC.Conc (setNumCapabilities)
stage :: Int -> A.Acc (A.Vector Double) -> A.Acc (A.Vector Double)
stage n input = foldl1 (A.zipWith (+)) [A.map (\x -> x + A.constant (fromIntegral (n + i))) input | i <- [1 .. 8 :: Int]]
program :: Int -> A.Acc (A.Vector Double) -> A.Acc (A.Vector Double)
program n input = foldl (\x f -> f x) input (replicate 40 (stage n A.>-> stage (n + 1)))
main :: IO ()
main = do
setNumCapabilities 8
forM_ [1 .. 1000 :: Int] $ \n -> do
_ <- evaluate (length (show (Sharing.convertAfun (program n))))
when (n `mod` 100 == 0) (print n)
With Accelerate installed and available to GHC:
ghc -O1 -threaded -rtsopts -package accelerate Main.hs -o repro
./repro +RTS -A64k -RTS
Expected behavior
All 1000 graph conversions complete successfully.
Actual behavior
Sharing recovery fails with an internal error:
Encountered duplicate 'ATag's
3116: Atag 1, 3100: Atag 1
CallStack (from HasCallStack):
internalError: Data.Array.Accelerate.Trafo.Sharing:2243:19
buildInitialEnvAcc: Data.Array.Accelerate.Trafo.Sharing:2623:48
scopesAfun1: Data.Array.Accelerate.Trafo.Sharing:2346:62
The failing iteration varies between runs.
Disabling parallel GC for the same executable:
./repro +RTS -A64k -qg -RTS
I tested five runs in each mode using the same executable, alternating between the two modes:
| GC mode | Runs | Duplicate ATag failures | Successful runs |
|---|---|---|---|
| Parallel GC | 5 | 3 | 2 |
Parallel GC disabled (-qg) |
5 | 0 | 5 |
All five runs with -qg completed 1000 conversions each: 5000 conversions with no errors. In the parallel-GC runs, two failures occurred after the progress message 400; another occurred before the first progress message (100).
Suspected cause
Sharing recovery requires physically shared Atag nodes, as described in Sharing.hs.
GHC's parallel copying GC can duplicate immutable constructors through copy_tag_nolock.
This suggests that physical copies of the same tag receive different stable names and
are subsequently rejected as duplicate tags during sharing recovery.
Discussion
Would it be feasible to fix this by identifying bound variables independently of physical sharing,
or by handling duplicated tags during environment construction?
I’d be happy to try working on a fix with some guidance.
I’m not very familiar with de Bruijn indices or the sharing recovery implementation,
and much of the investigation above was carried out with assistance from LLM,
however, I would like to extend my knowledge in this pretty interesting subject,
so I’d appreciate a review of the diagnosis and advice on where to start.
- Ngôn ngữ chính
- Haskell
- Star
- 1k
- Fork
- 138
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AccelerateHS/accelerate
-
link in readme brokenĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
AccelerateHS/accelerate#429 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
AccelerateHS/accelerate#589 ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 42/100
AccelerateHS/accelerate#586 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
AccelerateHS/accelerate#585 ·
-
New pipeline: atrace on PTXĐang mởgood first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
AccelerateHS/accelerate#582 ·
Tất cả issue của AccelerateHS/accelerate
Issue tương tự
-
bug dependencies
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
alunduil/network-arbitrary#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
haskell/statistics#235 ·
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
pkg:crucible-mir type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100