From 2031dd162995157c3f7830d68896b19b178b9146 Mon Sep 17 00:00:00 2001 From: Tim Rogers Date: Wed, 27 Jun 2012 14:57:05 -0800 Subject: Fixing a bug in the opencl prebuilt ptx flow. If a kernel made modidifcations to the .cl code at runtime (like changed the block size or some other constants) then recompiled itself the saved_embedded_ptx would just get overwritten. Same on using the prebuilt ptx file - I always wanted to load the same ptx file even though there should have been more than one. [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 13217] --- libopencl/opencl_runtime_api.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libopencl/opencl_runtime_api.cc') diff --git a/libopencl/opencl_runtime_api.cc b/libopencl/opencl_runtime_api.cc index 213b4b4..0b00556 100644 --- a/libopencl/opencl_runtime_api.cc +++ b/libopencl/opencl_runtime_api.cc @@ -181,6 +181,7 @@ struct _cl_program { private: cl_context m_context; std::map m_pgm; + static unsigned m_kernels_compiled; }; struct _cl_kernel { @@ -381,6 +382,7 @@ cl_mem _cl_context::lookup_mem( cl_mem m ) } } +unsigned _cl_program::m_kernels_compiled = 0; _cl_program::_cl_program( cl_context context, cl_uint count, const char ** strings, @@ -392,7 +394,8 @@ _cl_program::_cl_program( cl_context context, char *tmp = (char*)malloc(len+1); memcpy(tmp,strings[i],len); tmp[len] = 0; - m_pgm[i].m_source = tmp; + m_pgm[m_kernels_compiled].m_source = tmp; + ++m_kernels_compiled; free(tmp); } } -- cgit v1.3