[7/7] backend: Turn on ASM dump.

Submitted by Laura Ekstrand on July 27, 2015, 5:25 p.m.

Details

Message ID 1438017917-4304-8-git-send-email-laura.d.ekstrand@intel.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Laura Ekstrand July 27, 2015, 5:25 p.m.
Open the file specified for the ASM dump and write the assembly to it.
---
 backend/src/backend/gen_context.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

Patch hide | download patch | download mbox

diff --git a/backend/src/backend/gen_context.cpp b/backend/src/backend/gen_context.cpp
index 446b693..56946a3 100644
--- a/backend/src/backend/gen_context.cpp
+++ b/backend/src/backend/gen_context.cpp
@@ -2295,6 +2295,14 @@  namespace gbe
     if (OCL_OUTPUT_ASM)
       outputAssembly(stdout, genKernel);
 
+    if (this->asmFileName) {
+      FILE *asmDumpStream = fopen(this->asmFileName, "w");
+      if (asmDumpStream) {
+        outputAssembly(asmDumpStream, genKernel);
+        fclose(asmDumpStream);
+      }
+    }
+
     return true;
   }
 

Comments

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Laura Ekstrand

> Sent: Tuesday, July 28, 2015 1:25 AM

> To: beignet@lists.freedesktop.org

> Cc: Ekstrand, Laura D

> Subject: [Beignet] [PATCH 7/7] backend: Turn on ASM dump.

> 

> Open the file specified for the ASM dump and write the assembly to it.

> ---

>  backend/src/backend/gen_context.cpp | 8 ++++++++

>  1 file changed, 8 insertions(+)

> 

> diff --git a/backend/src/backend/gen_context.cpp

> b/backend/src/backend/gen_context.cpp

> index 446b693..56946a3 100644

> --- a/backend/src/backend/gen_context.cpp

> +++ b/backend/src/backend/gen_context.cpp

> @@ -2295,6 +2295,14 @@ namespace gbe

>      if (OCL_OUTPUT_ASM)

>        outputAssembly(stdout, genKernel);

> 

> +    if (this->asmFileName) {

> +      FILE *asmDumpStream = fopen(this->asmFileName, "w");

A program may contains several cl kernels. Opening with "w" would make the final asm file only contain the asm of the last one.
So, you may change to use "a", which would append the several cl kernels together.
But to be user-friendly, you may need to clear the file before outputting any assembly to the file in-case user run the program again and again.

See Program::buildFromUnit(), it will call compileKernel for all the cl kernel inside the cl program.
And the patch have little conflict with master version, need to rebase and add the sign-off-by
Other patch in the patchset just seem good.

Thanks!
Ruiling
> +      if (asmDumpStream) {

> +        outputAssembly(asmDumpStream, genKernel);

> +        fclose(asmDumpStream);

> +      }

> +    }

> +

>      return true;

>    }

> 

> --

> 2.1.0

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet
This is a revised patch set to enable the Gen ASM dump featuree
These patches are rebased on the latest Beignet codebase
It includes te changes requested by Ruiling Song.
Now the ASM dump file is cleared everytime a kernel/program is built
and then the ASM dump for each built kernel is appended to this file.