Use clCommandQueueWrapper in math_brute_force (#1463)

Simplify code by avoiding manual resource management.

This commit only modifies tests that use one queue per thread.  The
other unmodified tests are single-threaded and use the global
`gQueue`.

Original patch by Marco Antognini.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2022-08-24 10:31:32 +01:00
committed by GitHub
parent 9666ca3c70
commit c82dabd4bb
12 changed files with 36 additions and 24 deletions

View File

@@ -133,7 +133,9 @@ struct ThreadInfo
double maxErrorValue2; // position of the max error value (param 2). Init double maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -795,7 +797,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -131,7 +131,9 @@ struct ThreadInfo
double maxErrorValue2; // position of the max error value (param 2). Init double maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -952,7 +954,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -132,7 +132,9 @@ struct ThreadInfo
cl_int maxErrorValue2; // position of the max error value (param 2). Init cl_int maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -717,7 +719,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -130,7 +130,9 @@ struct ThreadInfo
cl_int maxErrorValue2; // position of the max error value (param 2). Init cl_int maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -710,7 +712,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -132,7 +132,9 @@ struct ThreadInfo
double maxErrorValue2; // position of the max error value (param 2). Init double maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -762,7 +764,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -130,7 +130,9 @@ struct ThreadInfo
double maxErrorValue2; // position of the max error value (param 2). Init double maxErrorValue2; // position of the max error value (param 2). Init
// to 0. // to 0.
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -889,7 +891,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -126,7 +126,9 @@ struct ThreadInfo
cl_mem inBuf2; // input buffer for the thread cl_mem inBuf2; // input buffer for the thread
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -707,7 +709,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -124,7 +124,9 @@ struct ThreadInfo
cl_mem inBuf2; // input buffer for the thread cl_mem inBuf2; // input buffer for the thread
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
MTdata d; MTdata d;
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -696,7 +698,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf2); clReleaseMemObject(threadInfo.inBuf2);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -118,7 +118,9 @@ struct ThreadInfo
{ {
cl_mem inBuf; // input buffer for the thread cl_mem inBuf; // input buffer for the thread
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -478,7 +480,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf); clReleaseMemObject(threadInfo.inBuf);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -117,7 +117,9 @@ struct ThreadInfo
{ {
cl_mem inBuf; // input buffer for the thread cl_mem inBuf; // input buffer for the thread
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -492,7 +494,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf); clReleaseMemObject(threadInfo.inBuf);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -120,7 +120,9 @@ struct ThreadInfo
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
float maxError; // max error value. Init to 0. float maxError; // max error value. Init to 0.
double maxErrorValue; // position of the max error value. Init to 0. double maxErrorValue; // position of the max error value. Init to 0.
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -516,7 +518,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf); clReleaseMemObject(threadInfo.inBuf);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;

View File

@@ -118,7 +118,9 @@ struct ThreadInfo
cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread cl_mem outBuf[VECTOR_SIZE_COUNT]; // output buffers for the thread
float maxError; // max error value. Init to 0. float maxError; // max error value. Init to 0.
double maxErrorValue; // position of the max error value. Init to 0. double maxErrorValue; // position of the max error value. Init to 0.
cl_command_queue tQueue; // per thread command queue to improve performance
// Per thread command queue to improve performance
clCommandQueueWrapper tQueue;
}; };
struct TestInfo struct TestInfo
@@ -693,7 +695,6 @@ exit:
clReleaseMemObject(threadInfo.inBuf); clReleaseMemObject(threadInfo.inBuf);
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++) for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
clReleaseMemObject(threadInfo.outBuf[j]); clReleaseMemObject(threadInfo.outBuf[j]);
clReleaseCommandQueue(threadInfo.tQueue);
} }
return error; return error;