Unexpected output indexing arrays with array values
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
Bắt đầu với ví dụ createKernel tối thiểu có thể tái hiện trong issue và chạy nó ở cả chế độ gpu và cpu, so sánh kết quả với đầu ra mong đợi. Điều tra đường dẫn lập chỉ mục mảng được kernel GPU sử dụng; hoàn tất nghĩa là chế độ gpu trả về các giá trị giống với chế độ cpu cho ví dụ này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả

What is wrong?
As part of a project that I'm trying to integrate GPU.js into to enhance performance, I've encountered some bizarre output when running a kernel. If indexing an array with another, the output appears to have been taken from the values of the inner array. This is best explained with an example.
Where does it happen?
See the following for a minimal reproducible example.
const gpu = new GPU({ mode: 'gpu' });
const arr1 = [0, 1, 3, 4];
const arr2 = [10, 11, 12, 13, 14];
const arrKernel = gpu.createKernel(function(arr1, arr2) {
return arr2[arr1[this.thread.x]];
}).setOutput([4]);
const result = arrKernel(arr1, arr2);
// Expected output: "10,11,13,14"
// jsfiddle output with mode: 'gpu': "0,1,4,0"
// jsfiddle output with mode: 'cpu': "10,11,13,14" (as expected)
console.log(result.toString());
- Create two arrays
- Use
this.thread.xto index the first, and use the values of that to index the second - Observe unexpected output
I have a JS fiddle that can recreate this issue at jsfiddle.net/TomWyllie/c5khtu9g/. The source of the seemingly arbitrary output seems to be the values in the inner array as I mentioned above. That is, if I had written return arr1[arr1[this.thread.x]]; instead of return arr2[arr1[this.thread.x]]; all would be as expected.
This was tested using:
- GPU.js 2.9.4
- GPU: NVIDIA GeForce GTX 1060 3GB
- Google Chrome Version 83.0.4103.97 (Official Build) (64-bit), but same issue in Firefox
- Windows 10
I couldn't replicate the issue on my phone (Samsung Galaxy S9) and haven't tried any other devices.
How important is this (1-5)?
Probably a 3 4, it's pretty annoying but is probably possible to work around in my use case. But it'd make things unnecessarily complicated and other people might spend time debugging not suspecting this has happened - it's a very strange result.
Other Comments
I am very new to GPU.js (like, < 1 week) so am not 100% sure if this is a genuine bug, or if I have somehow ventured into unsupported territory, but given that the expected result is returned in mode: cpu, and also in mode: gpu on my phone in the JS Fiddle I thought it'd be worth flagging up. If I've missed something stupid please do let me know!
Finally, although not relevant to this issue in case anybody is wondering about the context, my use-case is traversing a matrix in diagonals, as only the diagonals can be computed in parallel due to the recursive nature of each entry. This is part of a string alignment algorithm. I am using (or trying to) this.thread.x to parameterise the position along each diagonal, the indices of which are computed outside the kernel.
Any comments or thoughts much appreciated! 😊
- Ngôn ngữ chính
- JavaScript
- Star
- 15.5k
- Fork
- 663
- 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
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 gpujs/gpu.js
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
-
WebGL backend silently returns all zeros for long-running kernels (no GL error, no context loss)Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Bitwise result not correctĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Issue tương tự
-
Complexity: Small P-Feature: Projects page ready for merge team role: back end/devOps role: front end size: 0.25pt
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 67/100
bellingcat/toolkit#905 ·
-
self-care self-care:docs-build-time-investigator
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
githubnext/gh-aw-cao#14191 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
effort:low impact:medium RAG status: auto-triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
mastra-ai/mastra#25229 · 2 bình luận ·
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 88/100
sugarlabs/musicblocks#8984 ·
Maintainer thường phản hồi trong vòng 1 ngày