Use malloc to allocate storage for task parameters on Windows.

Fixes bug #55.  A number of tests were crashing on Windows due to the task
launch code using alloca to allocate space for the tasks' parameters.  On
Windows, the stack isn't generally big enough for this to be a good idea.
Also added an alignment parmaeter to ISPCMalloc() to pass the alignment
requirement along.
This commit is contained in:
Matt Pharr
2011-07-06 05:53:25 -07:00
parent 4d733af3c7
commit 6e4c165c7e
8 changed files with 80 additions and 14 deletions

View File

@@ -1375,13 +1375,25 @@ parallel execution.
If you use the task launch feature in ``ispc``, you must provide C/C++
implementations of two functions and link them into your final executable
file:
file. Although these functions may be implemented in either language, they
must have "C" linkage (i.e. their prototypes must be declared inside an
``extern "C"`` block if they are defined in C++.)
::
void ISPCLaunch(void *funcptr, void *data);
void ISPCSync();
On Windows, two additional functions must be provided to dynamically
allocate and free memory to store the arguments passed to tasks. (On OSX
and Linux, the stack provides memory for task arguments; on Windows, the
stack is generally not large enough to do this for large numbers of tasks.)
::
void *ISPCMalloc(int64_t size, int32_t alignment);
void ISPCFree(void *ptr);
These are called by the task launch code generated by the ``ispc``
compiler; the first is called to launch to launch a task and the second is
called to wait for, respectively. (Factoring them out in this way