Comments (6)
What would be the expected behaviour? According to the POSIX and C standards, malloc of size 0 behavior:
If the size of the space requested is 0, the behavior is implementation-defined: either a null pointer shall be returned, or the behavior shall be as if the size were some non-zero value, except that the behavior is undefined if the returned pointer is used to access an object
Which is technically what is happening. I am happy to return a nullptr if that makes detecting errors easier...
from computecpp-sdk.
I believe either one of TensorFlow or Eigen relies on size-zero allocations being allowed. In that case, a nullptr
would be a problem. However, I think the current behaviour isn't consistent with the second bullet point - shouldn't malloc return unique pointers? Moreover, this means that the PointerMapper will misbehave (what happens when you try to free once, or three times?)
from computecpp-sdk.
I agree with @DuncanMcBain . Either null or the equivalent of a non-zero allocation would be fine (although I believe there is some Eigen or Tensorflow requirement that prefers non-null). What's problematic is returning the same non-null address. There is actually a much more problematic case:
auto a = SYCLMalloc(0, pMap); // Returns 0x1000
auto b = SYCLMalloc(4096, pMap); // Returns 0x1000 + 0
if (a) {
SYCLFree(a, pMap); // b gets accidentally freed because it shares an address.
}
This is why POSIX says the equivalent of a non-zero allocation. It ensures allocations get unique addresses, and that free can determine what to actually release without aliasing other allocations.
from computecpp-sdk.
That makes sense to me. I didn't realize at first about the potential double free issue.
Thanks for the pull request from @Rbiessy, this is sorted out now. If you are happy with the solution I think we can close it.
from computecpp-sdk.
LGTM
from computecpp-sdk.
Thanks, all!
from computecpp-sdk.
Related Issues (20)
- terminate called after throwing an instance of 'cl::sycl::invalid_object_error' HOT 6
- CE1.3.0 ptxas fatal : Ptx assembly aborted due to errors (VS2015 + Win10) HOT 8
- Using compute++ with compiler different from /usr/bin/c++ HOT 7
- Terminated after throwing instance of cl::sycl::invalid_object_error HOT 13
- Can't compile samples: missing standard c++ headers HOT 12
- error: no matching function for call to 'clCreateProgramWithSource' HOT 5
- Enabling __CUDACC__ is a bold move HOT 3
- is_accessor trait requires exactly 5 template arguments HOT 4
- Error when running SYCL program with ComputeCpp on CMake : 'cl::sycl::invalid_object_error' HOT 5
- simple-vector-add.cpp throws cl::sycl::compile_program_error exception HOT 4
- Running SYCL program in MSVC Debug mode throws std::bad_array_new_length HOT 9
- cmath not found: Missing Header HOT 5
- atomic add for double HOT 1
- can't download computecpp HOT 1
- samples about atomic op
- about __SYCL_DEVICE_ONLY__ macro HOT 1
- Has ComputeCpp_DIR worked, ever? HOT 4
- Missing ComputeCpp.props error HOT 4
- Exception when running VS example code HOT 5
- MSVC new project not running HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from computecpp-sdk.