malcolm3141

Raw UAV crashes computer

Discussion created by malcolm3141 on Sep 14, 2010
Latest reply on Sep 15, 2010 by malcolm3141

The attached code crashes my computer. Can anyone tell me what I am doing wrong?

Catalyst 10.8 drivers, and Windows 7 x64.

 

#include <cal.h> #include <calcl.h> #include <stdio.h> #include <stdlib.h> #include <io.h> const char *_copy_1d = "il_cs_2_0\n" "dcl_num_thread_per_group 64, 1, 1\n" "dcl_raw_uav_id(0)\n" "dcl_raw_uav_id(1)\n" "dcl_cb cb0[1]\n" "dcl_literal l0, 4, 0, 0, 64\n" "umad24 r0.x, vThreadGrpID.x, l0.w, vTidInGrp.x\n" "ishl r1.x, r0.x, l0.x\n" "iadd r2.x, cb0[0].x, r1.x\n" "iadd r3.x, cb0[0].y, r1.x\n" "uav_raw_load_id(0) r4, r2.x\n" "uav_raw_store_id(1) mem.xyzw, r3.x, r4\n" "end\n"; #define CAL_CHECK(__stmnt, __err) \ if(__stmnt != CAL_RESULT_OK) { \ printf("%s:\n", __err); \ printf(" %s\n\n", calclGetErrorString()); \ exit(-1); \ } int main(int args, char *argv[]) { calInit(); CALobject obj = NULL; CAL_CHECK(calclCompile(&obj, CAL_LANGUAGE_IL, _copy_1d, CAL_TARGET_CYPRESS), "Error compiling kernel"); CALimage image = NULL; CAL_CHECK(calclLink(&image, &obj, 1), "Error linking kernel"); calclFreeObject(obj); // Create a context... CALdevice device = NULL; CAL_CHECK(calDeviceOpen(&device, 0), "Error opening device"); CALcontext ctx = NULL; CAL_CHECK(calCtxCreate(&ctx, device), "Error creating context"); // Get the kernel entry point... CALmodule module = NULL; CAL_CHECK(calModuleLoad(&module, ctx, image), "Error loading kernel module"); CALfunc func = NULL; CAL_CHECK(calModuleGetEntry(&func, ctx, module, "main"), "Error getting kernel entry point"); // Allocate some buffers... CALresource res1 = NULL, res2 = NULL, res_cb = NULL; CAL_CHECK(calResAllocLocal1D(&res1, device, 1048576, CAL_FORMAT_32BIT_TYPELESS, CAL_RESALLOC_GLOBAL_BUFFER), "Error creating resource 1"); CAL_CHECK(calResAllocLocal1D(&res2, device, 1048576, CAL_FORMAT_32BIT_TYPELESS, CAL_RESALLOC_GLOBAL_BUFFER), "Error creating resource 2"); CAL_CHECK(calResAllocRemote1D(&res_cb, &device, 1, 4, CAL_FORMAT_UINT_4, CAL_RESALLOC_GLOBAL_BUFFER | CAL_RESALLOC_CACHEABLE), "Error creating CB resource"); CALmem mem1 = NULL, mem2 = NULL, mem_cb = NULL; CAL_CHECK(calCtxGetMem(&mem1, ctx, res1), "Error mapping resource 1 into context"); CAL_CHECK(calCtxGetMem(&mem2, ctx, res2), "Error mapping resource 2 into context"); CAL_CHECK(calCtxGetMem(&mem_cb, ctx, res_cb), "Error mapping resource 2 into context"); int *ptr; CALuint pitch; CAL_CHECK(calResMap((void**)&ptr, &pitch, res_cb, 0), "Error mapping CB resource"); ptr[0] = 0; ptr[1] = 0; CAL_CHECK(calResUnmap(res_cb), "Error unmapping CB resource"); // Assign the resources to the kernel... CALname name; CAL_CHECK(calModuleGetName(&name, ctx, module, "uav0"), "Error getting name for uav0"); CAL_CHECK(calCtxSetMem(ctx, name, mem1), "Error setting mem for uav0"); CAL_CHECK(calModuleGetName(&name, ctx, module, "uav1"), "Error getting name for uav1"); CAL_CHECK(calCtxSetMem(ctx, name, mem2), "Error setting mem for uav1"); CAL_CHECK(calModuleGetName(&name, ctx, module, "cb0"), "Error getting name for cb0"); CAL_CHECK(calCtxSetMem(ctx, name, mem_cb), "Error setting mem for cb0"); // Then run the kernel... CALevent ev; CALprogramGrid grid; grid.func = func; grid.flags = 0; grid.gridBlock.width = 64; grid.gridBlock.height = 1; grid.gridBlock.depth = 1; grid.gridSize.width = 4096; grid.gridBlock.height = 1; grid.gridBlock.depth = 1; CAL_CHECK(calCtxRunProgramGrid(&ev, ctx, &grid), "Error running kernel"); while(calCtxIsEventDone(ctx, ev) == CAL_RESULT_PENDING) printf("."); return 0; }

Outcomes