<commit_before>#ifndef _CL_CONTEXT_H
#define _CL_CONTEXT_H

class CLContext;

typedef CLObjectReleasableInfoBase <
	cl_context,
	cl_context_info,
	CLContext
> CLContextBase;

class CLContext :
	public CLContextBase
{
	private:
		CLContext(cl_context id) : CLContextBase(id) {
			// AMD specific hack => can only have one context per app
			assert(NullMemStore::null_mem == NULL);
			cl_int err;
			NullMemStore::null_mem = clCreateBuffer(id, CL_MEM_READ_WRITE, 1, NULL, &err);
			assert(err == CL_SUCCESS && NullMemStore::null_mem != NULL);
		}

		friend void CLContextBase::free(CLError *error);

		~CLContext() {
			
		}

		friend class CLPlatform;
	public:
		static cl_int InfoFunc(cl_context id, cl_context_info info, size_t param_size, void* param_value, size_t* param_size_ret) {
			return clGetContextInfo(id, info, param_size, param_value, param_size_ret);
		}

		static cl_int ReleaseFunc(cl_context id) {
			// AMD specific hack
			assert(NullMemStore::null_mem);
			cl_int err = clReleaseMemObject(NullMemStore::null_mem);
			assert(err == CL_SUCCESS);
			return clReleaseContext(id);
		}

		std::list<CLDevice> getDevices(CLError *error) {
			CLErrGuard err(error);
			std::list<CLDevice> dlist;

			// get the number of devices
			size_t size;
			if(err = clGetContextInfo(id, CL_CONTEXT_DEVICES, 0, 0, &size))
				return dlist;

			// get the devices
			cl_device_id* devices = new cl_device_id[size/sizeof(cl_device_id)];
			if(err = clGetContextInfo(id, CL_CONTEXT_DEVICES, size, devices, 0)) {
				delete[] devices;
				return dlist;
			}

			// add the devices to the list<commit_msg>Fixed a crash due to not the integrator being constructed multiple times and global variables not being reset.<commit_after>#ifndef _CL_CONTEXT_H
#define _CL_CONTEXT_H

class CLContext;

typedef CLObjectReleasableInfoBase <
	cl_context,
	cl_context_info,
	CLContext
> CLContextBase;

class CLContext :
	public CLContextBase
{
	private:
		CLContext(cl_context id) : CLContextBase(id) {
			// AMD specific hack => can only have one context per app
			assert(NullMemStore::null_mem == NULL);
			cl_int err;
			NullMemStore::null_mem = clCreateBuffer(id, CL_MEM_READ_WRITE, 1, NULL, &err);
			assert(err == CL_SUCCESS && NullMemStore::null_mem != NULL);
		}

		friend void CLContextBase::free(CLError *error);

		~CLContext() {
			
		}

		friend class CLPlatform;
	public:
		static cl_int InfoFunc(cl_context id, cl_context_info info, size_t param_size, void* param_value, size_t* param_size_ret) {
			return clGetContextInfo(id, info, param_size, param_value, param_size_ret);
		}

		static cl_int ReleaseFunc(cl_context id) {
			// AMD specific hack
			assert(NullMemStore::null_mem);
			cl_int err = clReleaseMemObject(NullMemStore::null_mem);
			assert(err == CL_SUCCESS);
			NullMemStore::null_mem = NULL;
			return clReleaseContext(id);
		}

		std::list<CLDevice> getDevices(CLError *error) {
			CLErrGuard err(error);
			std::list<CLDevice> dlist;

			// get the number of devices
			size_t size;
			if(err = clGetContextInfo(id, CL_CONTEXT_DEVICES, 0, 0, &size))
				return dlist;

			// get the devices
			cl_device_id* devices = new cl_device_id[size/sizeof(cl_device_id)];
			if(err = clGetContextInfo(id, CL_CONTEXT_DEVICES, size, devices, 0)) {
				delete[] devices;
				return dlist;
			}

			// add the devices to the list
{'fraction_non_alphanumeric': 0.10164917541229385, 'fraction_numerical': 0.0023988005997001498, 'mean_word_length': 4.495881383855025, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4920283', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1136, 'n_words': 280}