Check that we can make at least one variable with size max_size which is returned from the device info property : CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE.
| 1572 | // max_size which is returned from the device info property : |
| 1573 | // CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE. |
| 1574 | static int l_capacity(cl_device_id device, cl_context context, |
| 1575 | cl_command_queue queue, size_t max_size) |
| 1576 | { |
| 1577 | int err = CL_SUCCESS; |
| 1578 | // Just test one type. |
| 1579 | const TypeInfo ti(l_find_type("uchar")); |
| 1580 | log_info(" l_capacity..."); |
| 1581 | |
| 1582 | const char prog_src_template[] = |
| 1583 | #if defined(_WIN32) |
| 1584 | "uchar var[%Iu];\n\n" |
| 1585 | #else |
| 1586 | "uchar var[%zu];\n\n" |
| 1587 | #endif |
| 1588 | "kernel void get_max_size( global ulong* size_ret ) {\n" |
| 1589 | #if defined(_WIN32) |
| 1590 | " *size_ret = (ulong)%Iu;\n" |
| 1591 | #else |
| 1592 | " *size_ret = (ulong)%zu;\n" |
| 1593 | #endif |
| 1594 | "}\n\n" |
| 1595 | "kernel void writer( global uchar* src ) {\n" |
| 1596 | " var[get_global_id(0)] = src[get_global_linear_id()];\n" |
| 1597 | "}\n\n" |
| 1598 | "kernel void reader( global uchar* dest ) {\n" |
| 1599 | " dest[get_global_linear_id()] = var[get_global_id(0)];\n" |
| 1600 | "}\n\n"; |
| 1601 | char prog_src[MAX_STR]; |
| 1602 | int num_printed = snprintf(prog_src, sizeof(prog_src), prog_src_template, |
| 1603 | max_size, max_size); |
| 1604 | assert(num_printed < MAX_STR); // or increase MAX_STR |
| 1605 | (void)num_printed; |
| 1606 | |
| 1607 | StringTable ksrc; |
| 1608 | ksrc.add(prog_src); |
| 1609 | |
| 1610 | int status = CL_SUCCESS; |
| 1611 | clProgramWrapper program; |
| 1612 | clKernelWrapper get_max_size; |
| 1613 | |
| 1614 | status = create_single_kernel_helper(context, &program, &get_max_size, |
| 1615 | ksrc.num_str(), ksrc.strs(), |
| 1616 | "get_max_size"); |
| 1617 | test_error_ret(status, "Failed to create program for capacity test", |
| 1618 | status); |
| 1619 | |
| 1620 | // Check size query. |
| 1621 | size_t used_bytes = 0; |
| 1622 | status = clGetProgramBuildInfo(program, device, |
| 1623 | CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, |
| 1624 | sizeof(used_bytes), &used_bytes, 0); |
| 1625 | test_error_ret(status, "Failed to query global variable total size", |
| 1626 | status); |
| 1627 | if (used_bytes < max_size) |
| 1628 | { |
| 1629 | log_error("Error: program query for global variable total size query " |
| 1630 | "failed: Expected at least %llu but got %llu\n", |
| 1631 | (unsigned long long)max_size, (unsigned long long)used_bytes); |
no test coverage detected