@@ -61,51 +61,51 @@ const unsigned int PrintfBufferSize = 4 * MB;
61
61
//
62
62
// FORMAT OF PRINTF OUTPUT BUFFER:
63
63
// ================================
64
- //
65
- // ======================================================================
66
- // | DWORD bufferSize Size of the buffer in bytes | <-- This value is incremented by atomic_add
67
- // |====================================================================|
68
- // | DWORD stringIndex_ch_0 Index of format string for channel 0 | \
69
- // |--------------------------------------------------------------------| |
70
- // | DWORD data0Type Type identifier | |
71
- // |--------------------------------------------------------------------| |
72
- // | DWORD data0 Data for channel 0 | |
73
- // |--------------------------------------------------------------------| | Channel 0 data
74
- // | . . . . . . | |
75
- // |--------------------------------------------------------------------| |
76
- // | DWORD data1Type Type identifier | |
77
- // |--------------------------------------------------------------------| |
78
- // | DWORD data1 Data for channel 0 | /
79
- // |====================================================================|
80
- // | DWORD stringIndex_ch_1 Index of format string for channel 1 | \
81
- // |--------------------------------------------------------------------| |
82
- // | DWORD data0Type Type identifier | |
83
- // |--------------------------------------------------------------------| |
84
- // | DWORD data0 Data for channel 1 | |
85
- // |--------------------------------------------------------------------| | Channel 1 data
86
- // | . . . . . . | |
87
- // |--------------------------------------------------------------------| |
88
- // | DWORD data0Type Type identifier | |
89
- // |--------------------------------------------------------------------| |
90
- // | DWORD data1 Data for channel 1 | /
91
- // |====================================================================|
92
- // | . . . . . . |
93
- // | . . . . . . |
94
- // | . . . . . . |
95
- // |====================================================================|
96
- // | DWORD stringIndex_ch_N Index of format string for channel N | \
97
- // |--------------------------------------------------------------------| |
98
- // | DWORD data0Type Type identifier | |
99
- // |--------------------------------------------------------------------| |
100
- // | DWORD data0 Data for channel N | |
101
- // |--------------------------------------------------------------------| | Channel N data
102
- // | . . . . . . | |
103
- // |--------------------------------------------------------------------| |
104
- // | DWORD data0Type Type identifier | |
105
- // |--------------------------------------------------------------------| |
106
- // | DWORD data1 Data for channel N | /
107
- // |--------------------------------------------------------------------|
108
-
64
+ /*
65
+ ======================================================================
66
+ | DWORD bufferSize Size of the buffer in bytes | <-- This value is incremented by atomic_add
67
+ |====================================================================|
68
+ | DWORD stringIndex_ch_0 Index of format string for channel 0 | \
69
+ |--------------------------------------------------------------------| |
70
+ | DWORD data0Type Type identifier | |
71
+ |--------------------------------------------------------------------| |
72
+ | DWORD data0 Data for channel 0 | |
73
+ |--------------------------------------------------------------------| | Channel 0 data
74
+ | . . . . . . | |
75
+ |--------------------------------------------------------------------| |
76
+ | DWORD data1Type Type identifier | |
77
+ |--------------------------------------------------------------------| |
78
+ | DWORD data1 Data for channel 0 | /
79
+ |====================================================================|
80
+ | DWORD stringIndex_ch_1 Index of format string for channel 1 | \
81
+ |--------------------------------------------------------------------| |
82
+ | DWORD data0Type Type identifier | |
83
+ |--------------------------------------------------------------------| |
84
+ | DWORD data0 Data for channel 1 | |
85
+ |--------------------------------------------------------------------| | Channel 1 data
86
+ | . . . . . . | |
87
+ |--------------------------------------------------------------------| |
88
+ | DWORD data0Type Type identifier | |
89
+ |--------------------------------------------------------------------| |
90
+ | DWORD data1 Data for channel 1 | /
91
+ |====================================================================|
92
+ | . . . . . . |
93
+ | . . . . . . |
94
+ | . . . . . . |
95
+ |====================================================================|
96
+ | DWORD stringIndex_ch_N Index of format string for channel N | \
97
+ |--------------------------------------------------------------------| |
98
+ | DWORD data0Type Type identifier | |
99
+ |--------------------------------------------------------------------| |
100
+ | DWORD data0 Data for channel N | |
101
+ |--------------------------------------------------------------------| | Channel N data
102
+ | . . . . . . | |
103
+ |--------------------------------------------------------------------| |
104
+ | DWORD data0Type Type identifier | |
105
+ |--------------------------------------------------------------------| |
106
+ | DWORD data1 Data for channel N | /
107
+ |--------------------------------------------------------------------|
108
+ */
109
109
110
110
// For vector arguments, 2 type identifiers are used: 1st is SHADER_PRINTF_VECTOR_* and 2nd is the vector length.
111
111
// These 2 type identifiers are followed by the elements of the vector.
@@ -342,58 +342,58 @@ static StoreInst* genStoreInternal(Value* Val, Value* Ptr, BasicBlock* InsertAtE
342
342
343
343
void OpenCLPrintfResolution::expandPrintfCall (CallInst& printfCall, Function& F)
344
344
{
345
- // Replace a printf call with IR instructions that fill the rintf
346
- // output buffer created by the Runtime:
347
- // --------------------------------------------------------------------------
348
- // bufferPtr - pointer to the printf output buffer. This pointer
349
- // is an implicit kernel argument. It is loaded into
350
- // GRF as part of thread payload.
351
- // bufferSize - size of the printf output buffer. By agreement with
352
- // Runtime, it is 4 Mb.
353
- // dataSize - size of printf data for current thread.
354
- //
355
- // Note: we use STATELESS mode for printf buffer access.
356
- // ---------------------------------------------------------------------------
357
- // writeOffset = atomic_add(bufferPtr, dataSize);
358
- // writePtr = bufferPtr + writeOffset;
359
- // endOffset = writeOffset + dataSize;
360
- // if (endOffset < bufferSize) { \
361
- // // Write the format string index |
362
- // *writePtr = stringIndex; |
363
- // writePtr += 4; |
364
- // |
365
- // // Write the argument type |
366
- // *writePtr = argument[1].dataType; |
367
- // writePtr += 4; |
368
- // // Write the argument value |
369
- // *writePtr = argument[1].value; |
370
- // writePtr += 4; | bblockTrue
371
- // . . . |
372
- // . . . |
373
- // // Write the argument type |
374
- // *writePtr = argument[N].dataType; |
375
- // writePtr += 4; |
376
- // // Write the argument value |
377
- // *writePtr = argument[N].value; |
378
- // writePtr += 4; |
379
- // |
380
- // // printf returns 0 if successful |
381
- // return_val = 0; /
382
- // }
383
- // else { \
384
- // // Check if the remaining output |
385
- // // buffer space is enough for writing |
386
- // //invalid string index. |
387
- // endOffset = writeOffset + 4; |
388
- // if (endOffset < bufferSize) { \ | bblockFalse
389
- // // Write the invalid string index. | bblockErrorString |
390
- // *writePtr = -1; | |
391
- // } / |
392
- // // printf returns -1 if failed |
393
- // return_val = -1; /
394
- // }
395
- // ----------------------------------------------------------------------
396
-
345
+ /* Replace a printf call with IR instructions that fill the rintf
346
+ output buffer created by the Runtime:
347
+ --------------------------------------------------------------------------
348
+ bufferPtr - pointer to the printf output buffer. This pointer
349
+ is an implicit kernel argument. It is loaded into
350
+ GRF as part of thread payload.
351
+ bufferSize - size of the printf output buffer. By agreement with
352
+ Runtime, it is 4 Mb.
353
+ dataSize - size of printf data for current thread.
354
+
355
+ Note: we use STATELESS mode for printf buffer access.
356
+ ---------------------------------------------------------------------------
357
+ writeOffset = atomic_add(bufferPtr, dataSize);
358
+ writePtr = bufferPtr + writeOffset;
359
+ endOffset = writeOffset + dataSize;
360
+ if (endOffset < bufferSize) { \
361
+ // Write the format string index |
362
+ *writePtr = stringIndex; |
363
+ writePtr += 4; |
364
+ |
365
+ // Write the argument type |
366
+ *writePtr = argument[1].dataType; |
367
+ writePtr += 4; |
368
+ // Write the argument value |
369
+ *writePtr = argument[1].value; |
370
+ writePtr += 4; | bblockTrue
371
+ . . . |
372
+ . . . |
373
+ // Write the argument type |
374
+ *writePtr = argument[N].dataType; |
375
+ writePtr += 4; |
376
+ // Write the argument value |
377
+ *writePtr = argument[N].value; |
378
+ writePtr += 4; |
379
+ |
380
+ // printf returns 0 if successful |
381
+ return_val = 0; /
382
+ }
383
+ else { \
384
+ // Check if the remaining output |
385
+ // buffer space is enough for writing |
386
+ //invalid string index. |
387
+ endOffset = writeOffset + 4; |
388
+ if (endOffset < bufferSize) { \ | bblockFalse
389
+ // Write the invalid string index. | bblockErrorString |
390
+ *writePtr = -1; | |
391
+ } / |
392
+ // printf returns -1 if failed |
393
+ return_val = -1; /
394
+ }
395
+ ----------------------------------------------------------------------
396
+ */
397
397
MetaDataUtils* MdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils ();
398
398
ImplicitArgs implicitArgs (F, MdUtils);
399
399
0 commit comments