Added updated task launch implementation that now tracks task groups.

Within each function that launches tasks, we now can easily track which
tasks that function launched, so that the sync at the end of the function
can just sync on the tasks launched by that function (not all tasks
launched by all functions.)

Implementing this led to a rework of the task system API that ispc generates
code to call; the example task systems in examples/tasksys.cpp have been
updated to conform to this API.  (The updated API is also documented in
the ispc user's guide.)

As part of this, "launch[n]" syntax was added to launch a number of tasks
in a single launch statement, rather than requiring a loop over 'n' to
launch n tasks.

This commit thus fixes issue #84 (enhancement to launch multiple tasks from
a single launch statement) as well as issue #105 (recursive task launches
were broken).
This commit is contained in:
Matt Pharr
2011-09-30 11:20:53 -07:00
parent 5ee4d7fce8
commit cb7976bbf6
43 changed files with 1309 additions and 1043 deletions

View File

@@ -58,23 +58,26 @@ extern "C" {
extern void f_di(float *result, double *a, int *b);
extern void result(float *val);
void ISPCLaunch(void *f, void *d);
void ISPCSync();
void *ISPCMalloc(int64_t size, int32_t alignment);
void ISPCFree(void *ptr);
void ISPCLaunch(void **handlePtr, void *f, void *d, int);
void ISPCSync(void *handle);
void *ISPCAlloc(void **handlePtr, int64_t size, int32_t alignment);
}
void ISPCLaunch(void *f, void *d) {
typedef void (*TaskFuncType)(void *, int, int);
void ISPCLaunch(void **handle, void *f, void *d, int count) {
*handle = (void *)0xdeadbeef;
typedef void (*TaskFuncType)(void *, int, int, int, int);
TaskFuncType func = (TaskFuncType)f;
func(d, 0, 1);
for (int i = 0; i < count; ++i)
func(d, 0, 1, i, count);
}
void ISPCSync() {
void ISPCSync(void *) {
}
void *ISPCMalloc(int64_t size, int32_t alignment) {
void *ISPCAlloc(void **handle, int64_t size, int32_t alignment) {
*handle = (void *)0xdeadbeef;
// and now, we leak...
#ifdef ISPC_IS_WINDOWS
return _aligned_malloc(size, alignment);
#endif
@@ -92,18 +95,6 @@ void *ISPCMalloc(int64_t size, int32_t alignment) {
}
void ISPCFree(void *ptr) {
#ifdef ISPC_IS_WINDOWS
_aligned_free(ptr);
#endif
#ifdef ISPC_IS_LINUX
free(ptr);
#endif
#ifdef ISPC_IS_APPLE
free(((void**)ptr)[-1]);
#endif
}
int main(int argc, char *argv[]) {
int w = width();