As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
The following code does compiles with intel/nVidia OpenCL compilers (both based on LLVM):
struct Foo{ float2 bar; };
void baz(){
global struct Foo* foo;
((float*)(&foo->bar))[1]=1;
}
The AMD compiler says invalid type conversion, and accepts the code only with the global qualification as:
((global float*))(&foo->bar))[1]=1;
Which is of them is right according to the specification? (And: should I report the non-conforming compiler(s) somewhere?)
The OpenCL spec allows nearly infinite flexibility when it comes to casting pointers. Basically, the rule is that you the programmer know what you are doing for your particular hardware. It doesn't address the specific issue of casting across memory spaces, so this should probably be considered undefined behavior. The differences between vendors is to be expected.
As the CL spec matures over time, you can expect issues like the above to be explicitly addressed, I'd guess.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Recently I started looking at functional languages to make some algorithmic parts of my application more reliable. Of course I bumped into Haskell. But it prepared too many surprises for me with its laziness. Sometimes simple things become very and very slow.
So I'm wondering is there a language I can use to write small algorithms in functional style but without unnecessary laziness which causes more problems then helps.
The program should be compiled into Win32/64 native code (preferably dll) and have comparable performance with C++.
OCaml is probably the closest to Haskell, but it's strict and impure. It's a successor to ML.
OCaml, ML, and Haskell can all be compiled to machine code on any common platform.
In my experience, though, laziness is usually a great feature once you get a sense for how it works.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am using shared memory (shmget system calls provided by C) to allocate shared memory from inside a RCpp program.
Here as i am not using standard Calloc function which is connected with memory management of R , is there any danger i should be aware of ?
Will the memory management of R sees the space allocated by shmget as free space and tries to over write anything to it ?
If that is the case , what can be done to avert this situation ?
Thanks
Vineeth
This shows a complete lack of understanding of R.
You can neither make R multithreaded just by linking to pthreads, or using OpenMP, or ... By the same token, "Writing R Extensions" is very clear about what can and cannot be done with memory allocation. I suggest you take a closer look at that manual.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
As written in the heading, my question is, why does TCP/IP use big endian encoding when transmitting data and not the alternative little-endian scheme?
RFC1700 stated it must be so. (and defined network byte order as big-endian).
The convention in the documentation of Internet Protocols is to
express numbers in decimal and to picture data in "big-endian" order
[COHEN]. That is, fields are described left to right, with the most
significant octet on the left and the least significant octet on the
right.
The reference they make is to
On Holy Wars and a Plea for Peace
Cohen, D.
Computer
The abstract can be found at IEN-137 or on this IEEE page.
Summary:
Which way is chosen does not make too much
difference. It is more important to agree upon an order than which
order is agreed upon.
It concludes that both big-endian and little-endian schemes could've been possible. There is no better/worse scheme, and either can be used in place of the other as long as it is consistent all across the system/protocol.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
With the rise of Scala.React I was wondering whether Qt's Signals & Slots mechanism would become obsolete when using Qt as a GUI framework for a Scala program. How would one of the two approaches excel in each of the following categories?
ease of coding, regarding conciseness and clarity
expressiveness: Does any technique provide possibilities that the other one does not (like with WPF's coerce mechanism of dependency properties)?
compile time type safety, e.g. when using QtScript to define Signals & Slots
performance - But would it actually matter in a GUI?
Suppose Scala.React was already in a completed state and well documented: When would you prefer one approach over the other?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Given an operation such as int myNum = 5 + (5 * 9) or any other mathematical operation, what portions of this statement, if any, are performed by the compiler? Which ones are performed at runtime? Obviously, constantly changing variables cannot be simplified on compile, but certain operations might be. Does the compiler even care to do any such simplification (such as making the above statement int myNum = 50;)? Does this even matter in terms of load, speed, or any other objective measurement?
Detail is key here, please expound upon your thoughts as much as possible.
I mean this to apply to any arithmetical operation.
Check out constant folding.
Constant folding is the process of simplifying constant expressions at compile time. Terms in constant expressions are typically simple literals, such as the integer 2, but can also be variables whose values are never modified, or variables explicitly marked as constant.