Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenCL] Better graphs for profiling results ... #3940

Open
kif opened this issue Sep 15, 2023 · 1 comment
Open

[OpenCL] Better graphs for profiling results ... #3940

kif opened this issue Sep 15, 2023 · 1 comment
Assignees

Comments

@kif
Copy link
Member

kif commented Sep 15, 2023

def log_profile(self):
        """If we are in profiling mode, prints out all timing for every single OpenCL call
        
        :param stats: if True, prints the statistics on each kernel instead of all execution timings
        :return: list of lines to print
        """
        total_time = 0.0
        stats = {}

        if self.profile:
            for e in self.events:
                if isinstance(e, ProfileDescription):
                    name = e[0]
                    t0 = e[1]
                    t1 = e[2]
                elif isinstance(e, EventDescription) or "__len__" in dir(e) and len(e) == 2:
                    name = e[0]
                    pr = e[1].profile
                    t0 = pr.start
                    t1 = pr.end
                else:
                    name = "?"
                    t0 = e.profile.start
                    t1 = e.profile.end

                et = 1e-6 * (t1 - t0)
                total_time += et
                if name in stats:
                        stats[name].append(et)
                else:
                        stats[name] = [et]
        return stats
log_profile(gpu)
from silx.opencl.processing import EventDescription, ProfileDescription
log_profile(gpu)
stats = log_profile(gpu)
import matplotlib.cbook as cbook
list(stats.keys())
import numpy
ary = numpy.zeros((len(stats),max(len(i) for i in stats.values())))
ary.shape
for i,k in enumerate(stats):
    ary[i] = stats[k]
import matplotlib.cbook as cbook
import matplotlib.pyplot as plt
fig, axs = plt.subplots()
axs.bxp(bstats[-1::-1], vert=False)
axs.set_xlabel("Runtime (ms)")
fig.suptitle("Runtime of different kernels Nvidia A5000")
fig.suptitle("Runtime of different kernels on Nvidia A5000")
axs.set_title("Average runtime timeit: 2.7ms, OpenCL: 2.2ms")
@kif kif self-assigned this Sep 15, 2023
@kif
Copy link
Member Author

kif commented Sep 15, 2023

Issue: what if the number of calls to the kernel differ ... use NaN ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant