static void printBuildError( cl_int error, cl_device_id device, SolverKgen kgen, const SubproblemDim *dims, const PGranularity *pgran, const CLBLASKernExtra *kextra, const char *source, const char *buildLog) { char name[128]; char dimStr[1024]; char pgranStr[1024]; char *p; MemoryPattern *mempat = NULL; unsigned int i, j; const char *s; name[0] = '\0'; clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(name), name, NULL); // lookup memory pattern s = NULL; for (i = 0; i < BLAS_FUNCTIONS_NUMBER; i++) { for (j = 0; j < clblasSolvers[i].nrPatterns; j++) { mempat = &clblasSolvers[i].memPatterns[j]; if (kgen == mempat->sops->genKernel) { s = kernelTypeString(kextra->kernType); break; } } if (s != NULL) { break; } } // sprintf Subproblem dimensions p = dimStr; for (i = 0; i < mempat->nrLevels; i++) { p = sprintfGranulation(p, dims, i); strcat(p, "; "); p += strlen(p); } // sprintf data parallelism granularity sprintf(pgranStr, "pgran->wgDim = %d, pgran->wgSize[0] = %u, " "pgran->wgSize[1] = %u, pgran->wfSize = %u", pgran->wgDim, pgran->wgSize[0], pgran->wgSize[1], pgran->wfSize); fprintf(stderr, "\n========================================================\n\n"); fprintf(stderr, "AN INTERNAL KERNEL BUILD ERROR OCCURRED!\n"); fprintf(stderr, "device name = %s\n", name); fprintf(stderr, "error = %d\n", error); fprintf(stderr, "memory pattern = %s, %s kernel generator\n", mempat->name, s); fprintf(stderr, "Subproblem dimensions: %s\n", dimStr); fprintf(stderr, "Parallelism granularity: %s\n", pgranStr); fprintf(stderr, "Kernel extra flags: %u\n", kextra->flags); fprintf(stderr, "Source:\n\n%s\n\n", source); fprintf(stderr, "--------------------------------------------------------\n\n"); if (buildLog) { fprintf(stderr, "Build log:\n\n%s\n", buildLog); } else { fprintf(stderr, "Build log is unavailable\n"); } fprintf(stderr, "========================================================\n\n"); }
void dumpKernel( const SolutionStep *step, CLBlasKernelType ktype) { FILE *file; char tmp[1024]; MemoryPattern *pattern; const char *s; const CLBlasKargs *kargs = (const CLBlasKargs*)&step->args; char *srcBuf; unsigned int i; fileNameFromSolution(tmp, step->funcID, step); file = fopen((const char*)tmp, "a+"); pattern = &clblasSolvers[step->funcID].memPatterns[step->patternID]; // now, dump the info sprintf(tmp, "offset M = %lu, offset N = %lu, offset A = %lu," "offset BX = %lu, offset CY = %lu\n", kargs->offsetM, kargs->offsetN, kargs->offA, kargs->offBX, kargs->offCY); fputs(tmp, file); sprintf(tmp, "Memory pattern = %s\n", pattern->name); fputs(tmp, file); s = kernelTypeString(ktype); sprintf(tmp, "Kernel type = %s\n", s); fputs(tmp, file); // data parallelism granularity if (step->pgran.wgDim == 1) { sprintf(tmp, "work group size = %u\n", step->pgran.wgSize[0]); } else { sprintf(tmp, "work group size = %u x %u\n", step->pgran.wgSize[0], step->pgran.wgSize[1]); } fputs(tmp, file); fputs("Problem granulation\n", file); for (i = 0; i < pattern->nrLevels; i++) { sprintf(tmp, "[%u]: ", i); fputs(tmp, file); sprintfGranulation(tmp, step->subdims, i); fputs(tmp, file); fputs("\n", file); } srcBuf = malloc(SRC_BUFSIZE); if (srcBuf != NULL) { clGetProgramInfo(step->kernels[ktype]->program, CL_PROGRAM_SOURCE, SRC_BUFSIZE, srcBuf, NULL); fputs("Kernel source:\n\n", file); fputs(srcBuf, file); } else { fputs("Kernel source: not available\n", file); } free(srcBuf); fputs("--------------------------------------------------------------" "------------------------------------------------------------\n", file); fclose(file); }