Confirm integer arithmetic edge case behaviour (e.g. division by 0)

Aperta
#1,632 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

The issue asks maintainers to decide whether OpenCL C keeps its non-fatal integer division behaviour (section 6.5.1, Arithmetic Operators) instead of C's undefined behaviour. The payload names no file in the repo, so start from the OpenCL C spec text it quotes and the linked LLVM Discourse RFC. Done means a maintainer records a decision and its rationale, and any wording change follows from it. Expect this to need spec-level discussion, not a quick edit.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

OpenCL C v3.1 s6.5.1 "Arithmetic Operators" states that:

Division on integer types which results in a value that lies outside of the range bounded by the maximum and minimum representable values of the integer type will not cause an exception but will result in an unspecified value.

and

A divide by zero with integer types does not cause an exception but will result in an unspecified value.

That is, OpenCL C expressions such as INT_MIN / -1 and x / 0 are supposed to produce an unspecified value without triggering any undefined behaviour. This has some implications for an OpenCL C compiler (and potentially the speed of the code it generates) as it needs to ensure the generated code does not trigger an exception for example.

Quoting @AaronBallman on llvm discourse:

I [...] question why OpenCL is intentionally breaking from the underlying C standard in this one specific case. This is undefined behavior in both C and C++, and OpenCL turning it into well-defined-but-unreliable behavior doesn’t seem particularly useful. It continues to seem like a bug with the OpenCL specification that an implementation would have to go to these lengths to implement this;

The OpenCL C specification has mentioned this behaviour since OpenCL 1.0, though I could not find the original motivation. I'm raising this issue to clarify whether we want to preserve this behaviour (and keep the deviation from C99); if we do, it would be great to provide a rationale.

Lingua principale
Python
Stelle
427
Fork
137
Merge medio
3g 21h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di KhronosGroup/OpenCL-Docs

Tutte le issue di KhronosGroup/OpenCL-Docs

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.