| 484 | } |
| 485 | |
| 486 | cl_ulong |
| 487 | deviceL1CacheSize( |
| 488 | cl_device_id device, |
| 489 | cl_ulong l2CacheSize, |
| 490 | cl_int *error) |
| 491 | { |
| 492 | const size_t MIN_CACHE_SIZE = 1024; |
| 493 | const size_t STEP = 1024; |
| 494 | size_t L2_SIZE = (size_t)l2CacheSize; |
| 495 | |
| 496 | /* Bigger number of rounds increases time measurement precision, |
| 497 | * but slows the test down. |
| 498 | */ |
| 499 | const unsigned int ROUNDS = 64; |
| 500 | |
| 501 | /* Repeat each kernel run sereval times for higher reliability. */ |
| 502 | const unsigned int RELIABILITY_ROUNDS = 10; |
| 503 | |
| 504 | cl_int err; |
| 505 | |
| 506 | cl_uint maxComputeUnits; |
| 507 | cl_bool imageSupport; |
| 508 | |
| 509 | cl_platform_id platform; |
| 510 | cl_context_properties props[3] = { CL_CONTEXT_PLATFORM, 0, 0 }; |
| 511 | cl_context ctx; |
| 512 | cl_command_queue queue; |
| 513 | cl_program program; |
| 514 | cl_kernel kernel; |
| 515 | cl_event event; |
| 516 | |
| 517 | cl_float *in; |
| 518 | size_t width, height; |
| 519 | const cl_image_format format = { CL_RGBA, CL_FLOAT }; |
| 520 | cl_mem imgIn; |
| 521 | size_t origin[3], region[3]; |
| 522 | |
| 523 | cl_float4 out; |
| 524 | cl_mem bufOut; |
| 525 | |
| 526 | size_t global_work_size, local_work_size; |
| 527 | cl_ulong start, end, avg; |
| 528 | cl_long *times; |
| 529 | cl_double d, max; |
| 530 | |
| 531 | size_t steps; |
| 532 | size_t i, t; |
| 533 | |
| 534 | /* Collect device properties. */ |
| 535 | err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, |
| 536 | sizeof(cl_uint), &maxComputeUnits, NULL); |
| 537 | if (err != CL_SUCCESS) { |
| 538 | if (error != NULL) { |
| 539 | *error = err; |
| 540 | } |
| 541 | return 0; |
| 542 | } |
| 543 | err = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, |
nothing calls this directly
no test coverage detected