fft_setup.cpp 16.1 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

//
// File:       fft_setup.cpp
//
// Version:    <1.0>
//
// Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Inc. ("Apple")
//             in consideration of your agreement to the following terms, and your use,
//             installation, modification or redistribution of this Apple software
//             constitutes acceptance of these terms.  If you do not agree with these
//             terms, please do not use, install, modify or redistribute this Apple
//             software.
//
//             In consideration of your agreement to abide by the following terms, and
//             subject to these terms, Apple grants you a personal, non - exclusive
//             license, under Apple's copyrights in this original Apple software ( the
//             "Apple Software" ), to use, reproduce, modify and redistribute the Apple
//             Software, with or without modifications, in source and / or binary forms;
//             provided that if you redistribute the Apple Software in its entirety and
//             without modifications, you must retain this notice and the following text
//             and disclaimers in all such redistributions of the Apple Software. Neither
//             the name, trademarks, service marks or logos of Apple Inc. may be used to
//             endorse or promote products derived from the Apple Software without specific
//             prior written permission from Apple.  Except as expressly stated in this
//             notice, no other rights or licenses, express or implied, are granted by
//             Apple herein, including but not limited to any patent rights that may be
//             infringed by your derivative works or by other works in which the Apple
//             Software may be incorporated.
//
//             The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
//             WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
//             WARRANTIES OF NON - INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
//             PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION
//             ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
//
//             IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
//             CONSEQUENTIAL DAMAGES ( INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
//             SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
//             INTERRUPTION ) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION
//             AND / OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER
//             UNDER THEORY OF CONTRACT, TORT ( INCLUDING NEGLIGENCE ), STRICT LIABILITY OR
//             OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright ( C ) 2008 Apple Inc. All Rights Reserved.
//
////////////////////////////////////////////////////////////////////////////////////////////////////


#include "fft_internal.h"
#include "fft_base_kernels.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>
#include <string>
#include <sstream>
58
#include <cmath>
59
#include <limits.h>
60
61
62
63
64

using namespace std;

extern void getKernelWorkDimensions(cl_fft_plan *plan, cl_fft_kernel_info *kernelInfo, cl_int *batchSize, size_t *gWorkItems, size_t *lWorkItems);

Oliver Bock's avatar
Oliver Bock committed
65
static void
66
67
getBlockConfigAndKernelString(cl_fft_plan *plan)
{
Oliver Bock's avatar
Oliver Bock committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    plan->temp_buffer_needed = 0;
    *plan->kernel_string += baseKernels;

    if(plan->format == clFFT_SplitComplexFormat)
        *plan->kernel_string += twistKernelPlannar;
    else
        *plan->kernel_string += twistKernelInterleaved;

    switch(plan->dim)
    {
        case clFFT_1D:
            FFT1D(plan, cl_fft_kernel_x);
            break;

        case clFFT_2D:
            FFT1D(plan, cl_fft_kernel_x);
            FFT1D(plan, cl_fft_kernel_y);
            break;

        case clFFT_3D:
            FFT1D(plan, cl_fft_kernel_x);
            FFT1D(plan, cl_fft_kernel_y);
            FFT1D(plan, cl_fft_kernel_z);
            break;

        default:
            return;
    }

    plan->temp_buffer_needed = 0;
    cl_fft_kernel_info *kInfo = plan->kernel_info;
    while(kInfo)
    {
        plan->temp_buffer_needed |= !kInfo->in_place_possible;
        kInfo = kInfo->next;
    }
104
105
}

Oliver Bock's avatar
Oliver Bock committed
106

107
108
109
static void
deleteKernelInfo(cl_fft_kernel_info *kInfo)
{
Oliver Bock's avatar
Oliver Bock committed
110
111
112
113
114
115
116
117
    if(kInfo)
    {
        if(kInfo->kernel_name)
            free(kInfo->kernel_name);
        if(kInfo->kernel)
            clReleaseKernel(kInfo->kernel);
        free(kInfo);
    }
118
119
120
121
122
123
124
}

static void
destroy_plan(cl_fft_plan *Plan)
{
    cl_fft_kernel_info *kernel_info = Plan->kernel_info;

Oliver Bock's avatar
Oliver Bock committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
    while(kernel_info)
    {
        cl_fft_kernel_info *tmp = kernel_info->next;
        deleteKernelInfo(kernel_info);
        kernel_info = tmp;
    }

    Plan->kernel_info = NULL;

    if(Plan->kernel_string)
    {
        delete Plan->kernel_string;
        Plan->kernel_string = NULL;
    }
    if(Plan->twist_kernel)
    {
        clReleaseKernel(Plan->twist_kernel);
        Plan->twist_kernel = NULL;
    }
    if(Plan->program)
    {
        clReleaseProgram(Plan->program);
        Plan->program = NULL;
    }
    if(Plan->tempmemobj)
    {
        clReleaseMemObject(Plan->tempmemobj);
        Plan->tempmemobj = NULL;
    }
    if(Plan->tempmemobj_real)
    {
        clReleaseMemObject(Plan->tempmemobj_real);
        Plan->tempmemobj_real = NULL;
    }
    if(Plan->tempmemobj_imag)
    {
        clReleaseMemObject(Plan->tempmemobj_imag);
        Plan->tempmemobj_imag = NULL;
    }
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

    if(Plan->sin_LUT_d1)
       {
        clReleaseMemObject(Plan->sin_LUT_d1);
    }

    if(Plan->sin_LUT_d2)
       {
        clReleaseMemObject(Plan->sin_LUT_d2);
    }

    if(Plan->cos_LUT_d1)
       {
        clReleaseMemObject(Plan->cos_LUT_d1);
    }

    if(Plan->cos_LUT_d2)
       {
        clReleaseMemObject(Plan->cos_LUT_d2);
    }

185
186
187
}

static int
Oliver Bock's avatar
Oliver Bock committed
188
createKernelList(cl_fft_plan *plan)
189
{
Oliver Bock's avatar
Oliver Bock committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
    cl_program program = plan->program;
    cl_fft_kernel_info *kernel_info = plan->kernel_info;

    cl_int err;
    while(kernel_info)
    {
        kernel_info->kernel = clCreateKernel(program, kernel_info->kernel_name, &err);
        if(!kernel_info->kernel || err != CL_SUCCESS)
            return err;
        kernel_info = kernel_info->next;
    }

    if(plan->format == clFFT_SplitComplexFormat)
        plan->twist_kernel = clCreateKernel(program, "clFFT_1DTwistSplit", &err);
    else
        plan->twist_kernel = clCreateKernel(program, "clFFT_1DTwistInterleaved", &err);

    if(!plan->twist_kernel || err)
        return err;

    return CL_SUCCESS;
211
212
213
}

int getMaxKernelWorkGroupSize(cl_fft_plan *plan, unsigned int *max_wg_size, unsigned int num_devices, cl_device_id *devices)
Oliver Bock's avatar
Oliver Bock committed
214
{
215
216
217
218
    int reg_needed = 0;
    *max_wg_size = INT_MAX;
    int err;
    size_t wg_size;
Oliver Bock's avatar
Oliver Bock committed
219

220
221
222
    unsigned int i;
    for(i = 0; i < num_devices; i++)
    {
Oliver Bock's avatar
Oliver Bock committed
223
224
225
226
227
228
        cl_fft_kernel_info *kInfo = plan->kernel_info;
        while(kInfo)
        {
            err = clGetKernelWorkGroupInfo(kInfo->kernel, devices[i], CL_KERNEL_WORK_GROUP_SIZE, sizeof(size_t), &wg_size, NULL);
            if(err != CL_SUCCESS)
                return -1;
Oliver Bock's avatar
Oliver Bock committed
229

Oliver Bock's avatar
Oliver Bock committed
230
231
            if(wg_size < kInfo->num_workitems_per_workgroup)
                reg_needed |= 1;
Oliver Bock's avatar
Oliver Bock committed
232

Oliver Bock's avatar
Oliver Bock committed
233
234
            if(*max_wg_size > wg_size)
                *max_wg_size = wg_size;
Oliver Bock's avatar
Oliver Bock committed
235

Oliver Bock's avatar
Oliver Bock committed
236
237
238
            kInfo = kInfo->next;
        }
    }
Oliver Bock's avatar
Oliver Bock committed
239

Oliver Bock's avatar
Oliver Bock committed
240
    return reg_needed;
Oliver Bock's avatar
Oliver Bock committed
241
}
242

Gaurav Khanna's avatar
Gaurav Khanna committed
243
244
245
246
247
248
#define ERR_MACRO(err) { \
                         if( err != CL_SUCCESS) \
                         { \
                           if(error_code) \
                               *error_code = err; \
                           clFFT_DestroyPlan((clFFT_Plan) plan); \
Oliver Bock's avatar
Oliver Bock committed
249
                           return (clFFT_Plan) NULL; \
Gaurav Khanna's avatar
Gaurav Khanna committed
250
                         } \
Oliver Bock's avatar
Oliver Bock committed
251
                       }
252

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
static
int precomputeSinCosLUTs(cl_fft_plan * plan,cl_int *error_code) {

    size_t i=0;
    cl_int err;
	
    float * tmpLUT;

    // find logN1,logN2, where 
    // n = 2^logN1 * 2^logN2 , and logN1=logN2 +/- 1
  
    size_t N=plan->n.x*plan->n.y*plan->n.z;

    plan->logN1=0;
    plan->logN2=0;

    size_t Nrem=N;
    
    while(Nrem > 1) {
        plan->logN1++;
        Nrem >>= 1;

        if(Nrem > 1) {
            plan->logN2++;
            Nrem >>= 1;
        }
    }		

    plan->N1 = 1 << plan->logN1;

    plan->N2 = 1 << plan->logN2;

    // we use logN1 >= logN2 to allocate a buffer that fits 
    // the greater of the two LUTs 
    tmpLUT = (float*) malloc( plan->N1 * sizeof(float));

    float * tmpLUT_sin1 = (float*) malloc( plan->N1 * sizeof(float));
    float * tmpLUT_sin2 = (float*) malloc( plan->N1 * sizeof(float));
    float * tmpLUT_cos1 = (float*) malloc( plan->N1 * sizeof(float));
    float * tmpLUT_cos2 = (float*) malloc( plan->N1 * sizeof(float));


/*
    if(tmpLUT==NULL) {
	// TODO: error handling
    }	
*/
    double PI2 = 8.0*atan(1.0);
	
    for(i=0; i < plan->N1; i++) {
        tmpLUT_sin1[i]=(float)sin(PI2 * (float) i / (float)N); 
    } 
    plan->sin_LUT_d1 = clCreateBuffer(plan->context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, plan->N1*sizeof(float),tmpLUT_sin1, &err);

    if( err != CL_SUCCESS) 
    { 
        if(error_code) 
            *error_code = err; 
        free(tmpLUT);
        return 1;
    } 

    
    for(i=0; i < plan->N1; i++) {
        tmpLUT_cos1[i]=(float)cos(PI2 * (float) i / (float)N);
    }
    plan->cos_LUT_d1 = clCreateBuffer(plan->context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, plan->N1*sizeof(float),tmpLUT_cos1, &err);
    if( err != CL_SUCCESS) 
    { 
        if(error_code) 
            *error_code = err; 
        free(tmpLUT);
        return 1;
    } 
    
    for(i=0; i < plan->N2; i++) {
        tmpLUT_sin2[i]=(float)sin(PI2 * (float) i / (float) plan->N2);
    }
    plan->sin_LUT_d2 = clCreateBuffer(plan->context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, plan->N2*sizeof(float),tmpLUT_sin2, &err);
    if( err != CL_SUCCESS) 
    { 
        if(error_code) 
            *error_code = err; 
        free(tmpLUT);
        return 1;
    } 
    
    for(i=0; i < plan->N2; i++) {
        tmpLUT_cos2[i]=(float)cos(PI2 * (float) i / (float) plan->N2);
    }
    plan->cos_LUT_d2 = clCreateBuffer(plan->context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, plan->N2*sizeof(float),tmpLUT_cos2, &err);
    if( err != CL_SUCCESS) 
    { 
        if(error_code) 
            *error_code = err; 
        free(tmpLUT);
        return 1;
    } 



    float diff=0.0f;

    for(int i = 0 ; i < N ; i++) {
        int ind1 = i & (plan->N1-1);
        int ind2 = i >> plan->logN1;

        float cos_ref = cos(-PI2 * (float) i / (float) N);
        float sin_ref = sin(-PI2 * (float) i / (float) N);

        float test_sin =-1.0*(tmpLUT_sin1[ind1]*tmpLUT_cos2[ind2]+tmpLUT_cos1[ind1] * tmpLUT_sin2[ind2]);
        float test_cos = tmpLUT_cos1[ind1]*tmpLUT_cos2[ind2]-tmpLUT_sin1[ind1] * tmpLUT_sin2[ind2];
     	
        float test_diff= std::abs(test_sin - sin_ref);
        if(test_diff > diff ) diff=test_diff;
        test_diff= std::abs(test_cos - cos_ref);
        if(test_diff > diff ) diff=test_diff;

 

    }	
    fprintf(stdout,"!!!!!!!!! %e !!!!!!!!!!!!\n",diff);
    

    free(tmpLUT);

    free(tmpLUT_sin1);
    free(tmpLUT_sin2);
    free(tmpLUT_cos1);
    free(tmpLUT_cos2);





    return 0;
}



393
394
395
clFFT_Plan
clFFT_CreatePlan(cl_context context, clFFT_Dim3 n, clFFT_Dimension dim, clFFT_DataFormat dataFormat, cl_int *error_code )
{
Oliver Bock's avatar
Oliver Bock committed
396
397
398
399
400
401
402
403
404
405
    int i;
    cl_int err;
    int isPow2 = 1;
    cl_fft_plan *plan = NULL;
    ostringstream kString;
    int num_devices;
    int gpu_found = 0;
    cl_device_id devices[16];
    size_t ret_size;
    cl_device_type device_type;
Oliver Bock's avatar
Oliver Bock committed
406

407
    if(!context)
Oliver Bock's avatar
Oliver Bock committed
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
        ERR_MACRO(CL_INVALID_VALUE);

    isPow2 |= n.x && !( (n.x - 1) & n.x );
    isPow2 |= n.y && !( (n.y - 1) & n.y );
    isPow2 |= n.z && !( (n.z - 1) & n.z );

    if(!isPow2)
        ERR_MACRO(CL_INVALID_VALUE);

    if( (dim == clFFT_1D && (n.y != 1 || n.z != 1)) || (dim == clFFT_2D && n.z != 1) )
        ERR_MACRO(CL_INVALID_VALUE);

    plan = (cl_fft_plan *) malloc(sizeof(cl_fft_plan));
    if(!plan)
        ERR_MACRO(CL_OUT_OF_RESOURCES);

    plan->context = context;
    clRetainContext(context);
    plan->n = n;
    plan->dim = dim;
    plan->format = dataFormat;
    plan->kernel_info = 0;
    plan->num_kernels = 0;
    plan->twist_kernel = 0;
    plan->program = 0;
    plan->temp_buffer_needed = 0;
    plan->last_batch_size = 0;
    plan->tempmemobj = 0;
    plan->tempmemobj_real = 0;
    plan->tempmemobj_imag = 0;
438
439
440
441
    plan->sin_LUT_d1=0;
    plan->sin_LUT_d2=0;
    plan->cos_LUT_d1=0;
    plan->cos_LUT_d2=0;
Oliver Bock's avatar
Oliver Bock committed
442
443
444
445
446
    plan->max_localmem_fft_size = 2048;
    plan->max_work_item_per_workgroup = 256;
    plan->max_radix = 16;
    plan->min_mem_coalesce_width = 16;
    plan->num_local_mem_banks = 16;
Oliver Bock's avatar
Oliver Bock committed
447

448
449
    precomputeSinCosLUTs(plan,error_code);
    
450
451
patch_kernel_source:

Oliver Bock's avatar
Oliver Bock committed
452
453
    plan->kernel_string = new string("");
    if(!plan->kernel_string)
454
455
        ERR_MACRO(CL_OUT_OF_RESOURCES);

Oliver Bock's avatar
Oliver Bock committed
456
    getBlockConfigAndKernelString(plan);
Oliver Bock's avatar
Oliver Bock committed
457

Oliver Bock's avatar
Oliver Bock committed
458
459
    const char *source_str = plan->kernel_string->c_str();
    plan->program = clCreateProgramWithSource(context, 1, (const char**) &source_str, NULL, &err);
460
461
    ERR_MACRO(err);

Oliver Bock's avatar
Oliver Bock committed
462
463
    err = clGetContextInfo(context, CL_CONTEXT_DEVICES, sizeof(devices), devices, &ret_size);
    ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
464

Oliver Bock's avatar
Oliver Bock committed
465
    num_devices = ret_size / sizeof(cl_device_id);
Oliver Bock's avatar
Oliver Bock committed
466

Oliver Bock's avatar
Oliver Bock committed
467
468
469
470
    for(i = 0; i < num_devices; i++)
    {
        err = clGetDeviceInfo(devices[i], CL_DEVICE_TYPE, sizeof(device_type), &device_type, NULL);
        ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
471

Oliver Bock's avatar
Oliver Bock committed
472
473
474
475
476
477
478
479
480
        if(device_type == CL_DEVICE_TYPE_GPU)
        {
            gpu_found = 1;
            err = clBuildProgram(plan->program, 1, &devices[i], "-cl-mad-enable", NULL, NULL);
            if (err != CL_SUCCESS)
            {
                char *build_log;
                char devicename[200];
                size_t log_size;
Oliver Bock's avatar
Oliver Bock committed
481

Oliver Bock's avatar
Oliver Bock committed
482
483
                err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
                ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
484

Oliver Bock's avatar
Oliver Bock committed
485
                build_log = (char *) malloc(log_size + 1);
Oliver Bock's avatar
Oliver Bock committed
486

Oliver Bock's avatar
Oliver Bock committed
487
488
                err = clGetProgramBuildInfo(plan->program, devices[i], CL_PROGRAM_BUILD_LOG, log_size, build_log, NULL);
                ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
489

Oliver Bock's avatar
Oliver Bock committed
490
491
                err = clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(devicename), devicename, NULL);
                ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
492

Oliver Bock's avatar
Oliver Bock committed
493
494
495
                fprintf(stdout, "FFT program build log on device %s\n", devicename);
                fprintf(stdout, "%s\n", build_log);
                free(build_log);
Oliver Bock's avatar
Oliver Bock committed
496

Oliver Bock's avatar
Oliver Bock committed
497
498
499
500
                ERR_MACRO(err);
            }
        }
    }
Oliver Bock's avatar
Oliver Bock committed
501

Oliver Bock's avatar
Oliver Bock committed
502
503
    if(!gpu_found)
        ERR_MACRO(CL_INVALID_CONTEXT);
Oliver Bock's avatar
Oliver Bock committed
504

Oliver Bock's avatar
Oliver Bock committed
505
    err = createKernelList(plan);
506
    ERR_MACRO(err);
Oliver Bock's avatar
Oliver Bock committed
507

508
    // we created program and kernels based on "some max work group size (default 256)" ... this work group size
Oliver Bock's avatar
Oliver Bock committed
509
510
    // may be larger than what kernel may execute with ... if thats the case we need to regenerate the kernel source
    // setting this as limit i.e max group size and rebuild.
Oliver Bock's avatar
Oliver Bock committed
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
    unsigned int max_kernel_wg_size;
    int patching_req = getMaxKernelWorkGroupSize(plan, &max_kernel_wg_size, num_devices, devices);
    if(patching_req == -1)
    {
        ERR_MACRO(err);
    }

    if(patching_req)
    {
        destroy_plan(plan);
        plan->max_work_item_per_workgroup = max_kernel_wg_size;
        goto patch_kernel_source;
    }

    cl_fft_kernel_info *kInfo = plan->kernel_info;
    while(kInfo)
    {
        plan->num_kernels++;
        kInfo = kInfo->next;
    }

    if(error_code)
        *error_code = CL_SUCCESS;

    return (clFFT_Plan) plan;
536
537
}

Oliver Bock's avatar
Oliver Bock committed
538
void
539
540
541
clFFT_DestroyPlan(clFFT_Plan plan)
{
    cl_fft_plan *Plan = (cl_fft_plan *) plan;
Oliver Bock's avatar
Oliver Bock committed
542
543
544
545
546
547
    if(Plan)
    {
        destroy_plan(Plan);
        clReleaseContext(Plan->context);
        free(Plan);
    }
548
549
550
551
}

void clFFT_DumpPlan( clFFT_Plan Plan, FILE *file)
{
Oliver Bock's avatar
Oliver Bock committed
552
553
554
555
556
557
558
559
560
561
562
563
564
565
    size_t gDim, lDim;
    FILE *out;
    if(!file)
        out = stdout;
    else
        out = file;

    cl_fft_plan *plan = (cl_fft_plan *) Plan;
    cl_fft_kernel_info *kInfo = plan->kernel_info;

    while(kInfo)
    {
        cl_int s = 1;
        getKernelWorkDimensions(plan, kInfo, &s, &gDim, &lDim);
566
        fprintf(out, "Run kernel %s with global dim = {%lu*BatchSize}, local dim={%lu}\n", kInfo->kernel_name, (unsigned long)gDim, (unsigned long)lDim);
Oliver Bock's avatar
Oliver Bock committed
567
568
569
        kInfo = kInfo->next;
    }
    fprintf(out, "%s\n", plan->kernel_string->c_str());
570
}