summaryrefslogtreecommitdiff
path: root/utests/get_cl_info.cpp
diff options
context:
space:
mode:
authorManasi Navare <manasi.d.navare@intel.com>2015-10-12 07:53:07 -0400
committerYang Rong <rong.r.yang@intel.com>2015-10-13 14:53:05 +0800
commit15ced6f6ed456f63401ac053c5ec109524af8ca8 (patch)
treeb0a7230abb8ad49a52cd8d8d520bec869d42e9c9 /utests/get_cl_info.cpp
parent430384ccae4cba983e533e507557dd5a50303601 (diff)
downloadbeignet-15ced6f6ed456f63401ac053c5ec109524af8ca8.tar.gz
utests: Added unit tests to test LLVM and ASM dump generation in a two step build process with clCompile and clLink APIs.
This patch adds two new tests to the unit tests. It uses the existing framework and data structures and tests the llvm/asm dump generation when these flags (-dump-opt-llvm, -dump-opt-asm) are passed as compile and link options to clCompileProgram and clLinkProgram APIs along with the dump file names. Method added: 1) get_compile_llvm_info() tests LLVM dump generation after clCompileProgram() stage 2) get_link_asm_info() tests Gen ASM dump generation after clLinkProgram() stage Signed-off-by: Manasi Navare <manasi.d.navare@intel.com> Reviewed-by: Ruiling Song <ruiling.song@intel.com>
Diffstat (limited to 'utests/get_cl_info.cpp')
-rw-r--r--utests/get_cl_info.cpp95
1 files changed, 95 insertions, 0 deletions
diff --git a/utests/get_cl_info.cpp b/utests/get_cl_info.cpp
index 7c03d957..3109c8e4 100644
--- a/utests/get_cl_info.cpp
+++ b/utests/get_cl_info.cpp
@@ -470,6 +470,101 @@ void get_build_asm_info(void)
MAKE_UTEST_FROM_FUNCTION(get_build_asm_info);
+void get_compile_llvm_info(void)
+{
+ map<cl_program_info, void *> maps;
+ cl_build_status expect_status;
+ char llvm_file[] = "test_llvm_dump.txt";
+ char compile_opt[] = "-dump-opt-llvm=test_llvm_dump.txt";
+ FILE *fp = NULL;
+
+ //Remove any pre-existing file
+ if( (fp = fopen(llvm_file, "r")) != NULL) {
+ fclose(fp);
+ std::remove(llvm_file);
+ }
+
+ OCL_CALL (cl_kernel_compile, "compiler_if_else.cl", "compiler_if_else", compile_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))));
+
+
+ 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;
+ }
+ }
+
+ //Test is successful if the backend created the file
+ if( (fp = fopen(llvm_file, "r")) == NULL) {
+ std::cout << "LLVM file creation.. FAILED";
+ OCL_ASSERT(0);
+ } else {
+ fclose(fp);
+ std::cout << "LLVM file created.. SUCCESS";
+ }
+
+}
+
+MAKE_UTEST_FROM_FUNCTION(get_compile_llvm_info);
+
+void get_link_asm_info(void)
+{
+ map<cl_program_info, void *> maps;
+ cl_build_status expect_status;
+ char asm_file[] = "test_asm_dump.txt";
+ char link_opt[] = "-dump-opt-asm=test_asm_dump.txt";
+ FILE *fp = NULL;
+
+ //Remove any pre-existing file
+ if( (fp = fopen(asm_file, "r")) != NULL) {
+ fclose(fp);
+ std::remove(asm_file);
+ }
+
+ OCL_CALL (cl_kernel_link, "compiler_if_else.cl", "compiler_if_else", link_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))));
+
+
+ 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;
+ }
+ }
+
+ //Test is successful if the backend created the file
+ if( (fp = fopen(asm_file, "r")) == NULL) {
+ std::cout << "ASM file creation.. FAILED";
+ OCL_ASSERT(0);
+ } else {
+ fclose(fp);
+ std::cout << "ASM file created.. SUCCESS";
+ }
+}
+
+MAKE_UTEST_FROM_FUNCTION(get_link_asm_info);
+
/* ***************************************************** *
* clGetContextInfo *