Hash :
c0d806b4
Author :
Date :
2025-02-10T23:01:33
CL: OpenCL support for ANGLE Capture/Replay Implementation of OpenCL Capture/Replay tool in ANGLE. Brief notes about the change: - Most meaningful changes for the capture process are made in src/libANGLE/capture/ - Most meaningful changes for replay are made in util/capture/ and src/tests/perf_tests/ - Many autogenerated files are changed/added to allow the capture of OpenCL objects & calls - The following applications were captured/replayed: benchmark_model, GeekBench Compute, GeekBench ML, AI-Benchmark, various OCL CTS tests - End2end test added to capture_tests. CapturedTestCL.MultiFrameCL/ES3_Vulkan Bug: angleproject:383841335 Change-Id: I55fdaa6cd6c7ba740aaa2351e4d29050059d6d1d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6102105 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: Roman Lavrov <romanl@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
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 58 59 60 61 62 63 64 65 66 67 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 104 105 106 107 108 109 110 111 112 113 114
#include "CapturedTestCL_MultiFrameCL_ES3_Vulkan.h"
#include "trace_fixture_cl.h"
const char clGetExtensionFunctionAddress_func_name_0[] = { "clIcdGetPlatformIDsKHR" };
const char * clCreateProgramWithSource_strings_0[] = {
"\n"
" __kernel void frame1(__global float *output)\n"
" {\n"
" int gid = get_global_id(0);\n"
" output[gid] = gid * 2.0f;\n"
" }\n"
"\n"
" __kernel void frame2(__global float *output)\n"
" {\n"
" int gid = get_global_id(0);\n"
" output[gid] = gid * gid;\n"
" }\n"
"\n"
" __kernel void frame3(__global float *output)\n"
" {\n"
" int gid = get_global_id(0);\n"
" output[gid] = gid + 100.0f;\n"
" }\n"
"\n"
" __kernel void frame4(__global float *output)\n"
" {\n"
" int gid = get_global_id(0);\n"
" output[gid] = gid;\n"
" if (gid == 0)\n"
" {\n"
" printf(\"Frame 4!\\n\");\n"
" }\n"
" }\n"
"\n"
" __kernel void frame5(__global float *output)\n"
" {\n"
" int gid = get_global_id(0);\n"
" output[gid] = gid/gid;\n"
" }\n"
" ",
};
const char clCreateKernel_kernel_name_4[] = { "frame1" };
// Private Functions
void InitReplay(void)
{
// binaryDataFileName = CapturedTestCL_MultiFrameCL_ES3_Vulkan.angledata
// maxClientArraySize = 0
// readBufferSize = 512
// clPlatformsMapSize = 8
// clDevicesMapSize = 8
// clContextsMapSize = 8
// clCommandQueuesMapSize = 8
// clMemMapSize = 8
// clEventsMapSize = 0
// clProgramsMapSize = 8
// clKernelsMapSize = 16
// clSamplerMapSize = 0
// clVoidMapSize = 0
InitializeReplayCL("CapturedTestCL_MultiFrameCL_ES3_Vulkan.angledata", 0, 512, 8, 8, 8, 8, 8, 0, 8, 16, 0, 0);
}
// Public Functions
void ReplayFrame(uint32_t frameIndex)
{
switch (frameIndex)
{
case 2:
ReplayFrame2();
break;
case 3:
ReplayFrame3();
break;
case 4:
ReplayFrame4();
break;
case 5:
ReplayFrame5();
break;
default:
break;
}
}
void SetupFirstFrame()
{
clIcdGetPlatformIDsKHR = (clIcdGetPlatformIDsKHR_fn)clGetExtensionFunctionAddress(clGetExtensionFunctionAddress_func_name_0);
clGetPlatformIDs(1, clPlatformsMap, NULL);
temporaryDevicesList.clear();
temporaryDevicesList.resize(1);
clGetDeviceIDs(clPlatformsMap[0], 4, 1, temporaryDevicesList.data(), NULL);
clDevicesMap[0] = temporaryDevicesList[0];
temporaryDevicesList = {clDevicesMap[0]};
clContextsMap[0] = clCreateContext(NULL, 1, temporaryDevicesList.data(), NULL, 0, NULL);
clCommandQueuesMap[0] = clCreateCommandQueue(clContextsMap[0], clDevicesMap[0], 0, NULL);
clProgramsMap[0] = clCreateProgramWithSource(clContextsMap[0], 1, clCreateProgramWithSource_strings_0, NULL, NULL);
clBuildProgram(clProgramsMap[0], 0, NULL, 0, NULL, 0);
clMemMap[0] = clCreateBuffer(clContextsMap[0], 1, 512, 0, NULL);
clKernelsMap[0] = clCreateKernel(clProgramsMap[0], clCreateKernel_kernel_name_4, NULL);
clSetKernelArg(clKernelsMap[0], 0, 8, (const void *)&clMemMap[0]);
clEnqueueWriteBuffer(clCommandQueuesMap[0], clMemMap[0], 1, 0, 512, (const GLubyte *)&gBinaryData[64], 0, NULL, NULL);
}
void ResetReplay(void)
{
clReleaseContext(clContextsMap[0]);
clReleaseCommandQueue(clCommandQueuesMap[0]);
clReleaseProgram(clProgramsMap[0]);
clReleaseMemObject(clMemMap[0]);
clReleaseKernel(clKernelsMap[1]);
}