Closed GoogleCodeExporter closed 9 years ago
I agree with the scheduling of the proposal.
I agree that MYTHREAD/upc_threadof is the main issue, but I would also like to
see upc_addr_t (upc_addrfield_t? something like that) and upc_phase_t
(upc_blocksize_t? something like that) introduced. upc_blocksizeof and
upc_phaseof can return the same type. Only upc_blocksizeof returns something
that can be called a size.
Side note, I really dislike rampant use of casting. It can cover a multitude
of problems.
Original comment by brian.wibecan
on 22 May 2012 at 9:51
As noted in issue 33, MYTHREAD and THREADS are currently specified as
"EXPRESSIONS with a value of type int". This should not be confused with
"objects with a value of type int". This was an deliberate decision intended to
prevent exactly the sort of potential pitfalls described above.
By ISO-C 6.5.16.1: "In simple assignment (=), the value of the right operand is
converted to the type of the assignment expression and replaces the value
stored in the object designated by the left operand."
This implies that MYTHREAD and THREADS should already be assignment compatible
with any integral type on the LHS, and no warnings should occur. Truncation
occurs during assignment, so whether or not an overflow occurs is determined by
whether the object type of the LHS provided by the user was sufficiently wide
to hold the value.
If anything I believe the current spec says too much about the expression type
- it should be sufficient to relax the phrase "of type int" to "of integral
type". This would leave the exact type up to the implementation, which can
choose an appropriately wide expression type.
I think there's a separate issue here of whether upc.h should provide an
integral typedef for a type which is guaranteed to be sufficiently wide to
represent THREADS for the current translation environment. This would be as a
convenience to users who wish to portably store thread ids in their data
structures, but is not directly related to the type of THREADS and MYTHREAD.
On the issue of upc_threadof(), this is a library function and as such required
specifying a declared return type, for the purposes of type compatibility
checking, etc. size_t was convenient and guaranteed to be sufficiently wide,
because the expression sizeof(shared [1] char [THREADS]) is specified to have
type size_t. By this logic size_t can also currently be used to serve as the
convenience type mentioned above.
If we decide to introduce a convenience type for thread ids it would make sense
to amend the return type.
Original comment by danbonachea
on 31 May 2012 at 6:17
As owner for this issue, and based on the comments made so far, I am proposing
the following "resolution".
Proposed for UPC 1.3:
Replace, as Dan suggests, the phrase "with a value of type int" with EITHER
"of intergral type" OR "of unsigned intergral type"
This would *not*, as far as I can determine, introduce backward compatibility
problems (correct me if I am wrong) if current implementation don't actually
change their types. It "opens the door" for such a change later.
We do still need to agree on the signed/unsigned issue (my vote is for
UNsigned).
The unsigned choice would, at least, resolve the warnings which some compilers
produce when mixing signed and unsigned types.
Proposed for UPC 2.0:
Define a "upc_thread_t" to replace the return type of upc_threadof()
This is "unsafe" (and thus not for 1.x) because either narrowing or widening of
any type is not backwards-compatible (think "%z" in a printf).
Original comment by phhargr...@lbl.gov
on 31 May 2012 at 6:01
Original comment by phhargr...@lbl.gov
on 1 Jun 2012 at 3:20
Original comment by phhargr...@lbl.gov
on 1 Jun 2012 at 6:09
Update summary to match nature of current proposal
Original comment by phhargr...@lbl.gov
on 14 Jun 2012 at 11:09
The idea of this relaxation is to let the implementation entirely determine an
appropriate expression type, since the semantics of assignment already ensure
implicit conversion that prohibit any compiler warnings and prevent the user
from even observing what type is in use for that expression by the compiler.
Upon further digging, C99 uses the abstract term "integral" to refer to a value
which is mathematically an integer (ie a value with no fractional component).
It is not used to refer to the language type system, and the terms "signed",
"unsigned" and "type" do not appear anywhere with "integral".
Amended proposal for 1.3 spec:
"MYTHREAD/THREADS is an expression with integral value;"
The subsequent sentence in each paragraph already make it clear that THREADS >
0 and MYTHREAD >= 0.
Original comment by danbonachea
on 15 Jun 2012 at 7:37
I endorse Dan's amended proposal appearing in comment #7.
Original comment by phhargr...@lbl.gov
on 15 Jun 2012 at 7:43
Proposed Change (omitting changebar markup):
--------------------------------------------------------------------
--- upc-language.tex (revision 80)
+++ upc-language.tex (working copy)
@@ -71,15 +71,18 @@
\subsubsection{{\tt THREADS}}
\label{threads}
\index{THREADS}
-\npf{\tt THREADS} is an expression with a value of type int; it specifies the
number of
+\npf{\tt THREADS} is an expression with integral value; it specifies the
number of
threads and has the same value on every
thread. Under the static THREADS translation environment, {\tt THREADS}
is an integer constant suitable for use in {\tt \#if} preprocessing directives.
\subsubsection{{\tt MYTHREAD}}
\index{MYTHREAD}
-\npf{\tt MYTHREAD} is an expression with a value of type int; it specifies the
+\npf{\tt MYTHREAD} is an expression with integral value; it specifies the
unique thread index.
Original comment by danbonachea
on 16 Aug 2012 at 10:55
Mass-edit to mark all issues with an officially-announced resolution diff as
"PendingApproval"
Original comment by danbonachea
on 17 Aug 2012 at 3:25
Set Consensus:High on Pending Approval issues.
Original comment by gary.funck
on 19 Aug 2012 at 11:31
Comment #9 applied in SVN r111
Original comment by danbonachea
on 14 Sep 2012 at 12:48
Original comment by danbonachea
on 14 Sep 2012 at 12:56
For the record:
Public comment period for this change was 8/14/2012 - 9/14/2012
No substantial objections were raised or recorded during that period.
At the 9/7/2012 telecon, it was announced this change was imminent, feedback
was explicitly solicited, and none was received.
The change was integrated into a working draft distributed on 9/13/2012 for
consideration and draft ratification at the 9/14/2012 telecon.
Original comment by danbonachea
on 14 Sep 2012 at 7:26
Changes distributed as Draft 1.1 were ratified during the 9/14/2012
teleconference, for inclusion in the next public draft.
Original comment by danbonachea
on 14 Sep 2012 at 9:46
Original issue reported on code.google.com by
phhargr...@lbl.gov
on 22 May 2012 at 2:17