[Beignet] [PATCH] utests: Added unit tests to test LLVM and ASM dump generation.

Song, Ruiling ruiling.song at intel.com
Tue Sep 1 23:52:15 PDT 2015


I have two inline comments in get_build_llvm_info(), and the same with get_build_asm_info().
Please check it. And could you help include a "Sign-off" in your patch?

Thanks!
Ruiling
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Sirisha Gandikota
> Sent: Tuesday, September 1, 2015 11:44 AM
> To: Zou, Nanhai; beignet at lists.freedesktop.org
> Cc: Gandikota, Sirisha
> Subject: [Beignet] [PATCH] utests: Added unit tests to test LLVM and ASM dump
> generation.
> 
> 1) get_build_llvm_info() tests LLVM dump generation
> 2) get_build_asm_info() tests ASM dump generation
> ---
>  utests/get_cl_info.cpp | 91
> ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp index
> e2dc0d7..35d5442 100644
> --- a/utests/get_cl_info.cpp
> +++ b/utests/get_cl_info.cpp
> @@ -364,6 +364,97 @@ void get_program_build_info(void)
> 
>  MAKE_UTEST_FROM_FUNCTION(get_program_build_info);
> 
> +
> +// This method uses clGetProgramBuildInfo to check the llvm dump build
> +options sent // and verifies that the llvm dump file is actually generated in the
> backend.
> +void get_build_llvm_info(void)
> +{
> +    map<cl_program_info, void *> maps;
> +    cl_build_status expect_status;
> +    char llvm_file[] = "test_llvm_dump.txt";
> +    char build_opt[] = "-dump-opt-llvm=test_llvm_dump.txt";
> +    FILE *fp = NULL;
> +    int sz;
> +

I think you need to check whether test_llvm_dmp.txt exist or not, if it already exists, please delete it. So that we know the dump logic really works.

> +    OCL_CALL (cl_kernel_init, "compiler_if_else.cl",
> + "compiler_if_else", SOURCE, build_opt);
> +
> +    /* Do our test.*/
> +    expect_status = CL_BUILD_SUCCESS;
> +    maps.insert(make_pair(CL_PROGRAM_BUILD_STATUS,
> +                          (void *)(new Info_Result<cl_build_status>(expect_status))));
> +    sz = strlen(build_opt) + 1;
> +    maps.insert(make_pair(CL_PROGRAM_BUILD_OPTIONS,
> +                          (void *)(new Info_Result<char *>(build_opt,
> + sz))));
> +
> +    for (map<cl_program_info, void *>::iterator x = maps.begin(); x !=
> maps.end(); ++x) {
> +        switch (x->first) {
> +        case CL_PROGRAM_BUILD_STATUS:
> +            CALL_PROG_BUILD_INFO_AND_RET(cl_build_status);
> +            break;
> +        case CL_PROGRAM_BUILD_OPTIONS:
> +            CALL_PROG_BUILD_INFO_AND_RET(char *);
> +            break;
> +        default:
> +            break;
> +        }
> +    }
> +
> +    if( (fp = fopen(llvm_file, "r")) == NULL) {
> +      std::cout << "LLVM file creation.. FAILED";

Please add an "OCL_ASSERT(0);"  here, we will collect the pass rate, explicite assert() will let the utest runner know that the case failed.

> +    } else {
> +      fclose(fp);
> +      std::cout << "LLVM file created.. SUCCESS";
> +    }
> +}
> +
> +MAKE_UTEST_FROM_FUNCTION(get_build_llvm_info);
> +
> +
> +// This method uses clGetProgramBuildInfo to check the asm dump build
> +options sent // And verifies that the asm dump file is actually generated in the
> backend.
> +void get_build_asm_info(void)
> +{
> +    map<cl_program_info, void *> maps;
> +    cl_build_status expect_status;
> +    char asm_file[] = "test_asm_dump.txt";
> +    char build_opt[] ="-dump-opt-asm=test_asm_dump.txt";
> +    FILE *fp = NULL;
> +    int sz;
> +
> +    OCL_CALL (cl_kernel_init, "compiler_if_else.cl",
> + "compiler_if_else", SOURCE, build_opt);
> +
> +    /* Do our test.*/
> +    expect_status = CL_BUILD_SUCCESS;
> +    maps.insert(make_pair(CL_PROGRAM_BUILD_STATUS,
> +                          (void *)(new Info_Result<cl_build_status>(expect_status))));
> +    sz = strlen(build_opt) + 1;
> +    maps.insert(make_pair(CL_PROGRAM_BUILD_OPTIONS,
> +                          (void *)(new Info_Result<char *>(build_opt,
> + sz))));
> +
> +    for (map<cl_program_info, void *>::iterator x = maps.begin(); x !=
> maps.end(); ++x) {
> +        switch (x->first) {
> +        case CL_PROGRAM_BUILD_STATUS:
> +            CALL_PROG_BUILD_INFO_AND_RET(cl_build_status);
> +            break;
> +        case CL_PROGRAM_BUILD_OPTIONS:
> +            CALL_PROG_BUILD_INFO_AND_RET(char *);
> +            break;
> +        default:
> +            break;
> +        }
> +    }
> +
> +    if( (fp = fopen(asm_file, "r")) == NULL) {
> +      std::cout << "ASM file creation.. FAILED";
> +    } else {
> +      fclose(fp);
> +      std::cout << "ASM file created.. SUCCESS";
> +    }
> +}
> +
> +MAKE_UTEST_FROM_FUNCTION(get_build_asm_info);
> +
> +
>  /* ***************************************************** *
>   * clGetContextInfo                                      *
>   * ***************************************************** */
> --
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list