Hello World program can't see the .cl file

I am using Visual Studio 2022 to run my first program. Here it is.


#include <CL/cl.hpp>
#include <iostream>
#include <fstream>

int main() 
	std::vector<cl::Platform> platforms;

	auto platform = platforms.front();
	std::vector<cl::Device> devices;
	platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);

	auto device = devices.front();

	std::ifstream helloWorldFile("HelloWorld.cl");
	std::string src(std::istreambuf_iterator<char>(helloWorldFile), (std::istreambuf_iterator<char>()) );

	cl::Program::Sources sources(1, std::make_pair(src.c_str(), src.length() + 1));

	cl::Context context(device);
	cl::Program program(context, sources);

	auto err = program.build("cl-std=CL1.2");

	char buf[16];
	cl::Buffer memBuf(context, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY, sizeof(buf));
	cl::Kernel kernel(program, "HelloWorld", &err);
	kernel.setArg(0, memBuf);

	cl::CommandQueue queue(context, device);
	queue.enqueueReadBuffer(memBuf, CL_TRUE, 0, sizeof(buf), buf);

	std::cout << buf << " - buf" << std::endl;


_kernel void HelloWorld(_global char* data)
	data[0] = 'H';
	data[1] = 'e';
	data[2] = 'l';
	data[3] = 'l';
	data[4] = 'o';
	data[5] = ' ';
	data[6] = 'W';
	data[7] = 'o';
	data[8] = 'r';
	data[9] = 'l';
	data[10] = 'd';
	data[11] = '!';
	data[12] = '\n';

Program output:

Could not open file: C:\Users\user\AppData\Local\Temp\dep-a2fcdd.d
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠ - buf

What is this file (dep-a2fcdd.d) and why it “Could not open”


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.