[ad_1]
Exception thrown at 0x00007FF94628AC4D (igc64.dll) in dpc please work!.exe: 0xC0000005: Entry violation studying location 0x0000000000000008.
press 2 choose gp
When i attempt use my intel gpu i get this error i can’t repair it!
utilizing laptop computer
making an attempt to make use of GPU 0
<——-CODE——–>
#embody <CL/sycl.hpp>
#embody <iostream>
#embody <fstream>
#embody <cmath>
#embody <chrono>
utilizing namespace sycl;
utilizing std::chrono::duration_cast;
utilizing std::chrono::milliseconds;
utilizing std::cout;
utilizing std::endl;
utilizing std::ofstream;
typedef std::chrono::steady_clock the_clock;
const int WIDTH = 1920;
const int HEIGHT = 1080;
const int MAX_ITERATIONS = 500;
uint32_t img[HEIGHT][WIDTH];
void write_tga(const char* filename)
{
ofstream outfile(filename, ofstream::binary);
uint8_t header[18] = {
0, // no img ID
0, // no color map
2, // uncompressed 24-bit img
0, 0, 0, 0, 0, // empty color map specification
0, 0, // X origin
0, 0, // Y origin
WIDTH & 0xFF, (WIDTH >>
HEIGHT & 0xFF, (HEIGHT >>
24, // bits per pixel
0, // img descriptor
};
outfile.write((const char*)header, 18);
for (int y = 0; y < HEIGHT; ++y)
{
for (int x = 0; x < WIDTH; ++x)
{
uint8_t pixel[3] = {
img[y][x] & 0xFF, // blue channel
(img[y][x] >>
(img[y][x] >> 16) & 0xFF, // crimson channel
};
outfile.write((const char*)pixel, 3);
}
}
outfile.shut();
if (!outfile)
{
// An error has occurred in some unspecified time in the future since we opened the file.
std::cout << “Error writing to ” << filename << std::endl;
exit(1);
}
}
void write_tgaK9(const char* filename, uint32_t* img)
{
std::ofstream file(filename, std::ios::binary);
// TGA header
uint8_t header[18] = { 0 };
header[2] = 2; // truecolor
header[12] = WIDTH & 0xFF;
header[13] = WIDTH >> 8;
header[14] = HEIGHT & 0xFF;
header[15] = HEIGHT >> 8;
header[16] = 24; // bits per pixel
file.write(reinterpret_cast<char*>(header), sizeof(header));
// Pixel information
for (int y = 0; y < HEIGHT; ++y)
{
for (int x = 0; x < WIDTH; ++x)
{
uint32_t pixel = img[y * WIDTH + x];
uint8_t b = pixel & 0xFF;
uint8_t g = (pixel >>
uint8_t r = (pixel >> 16) & 0xFF;
file.put(b);
file.put(g);
file.put(r);
}
}
file.shut();
}
struct ComplexF {
float x;
float y;
};
ComplexF c_add(ComplexF c1, ComplexF c2)
{
ComplexF tmp;
float a = c1.x;
float b = c1.y;
float c = c2.x;
float d = c2.y;
tmp.x = a + c;
tmp.y = b + d;
return tmp;
} // c_add
float c_abs(ComplexF c)
{
return sycl::sqrt(c.x * c.x + c.y * c.y);
} // c_abs
ComplexF c_mul(ComplexF c1, ComplexF c2)
{
ComplexF tmp;
float a = c1.x;
float b = c1.y;
float c = c2.x;
float d = c2.y;
tmp.x = a * c – b * d;
tmp.y = b * c + a * d;
return tmp;
} // c_mul
void selectDevice(queue& Q)
{
int whatToUse{};
std::cout << “Enter 1 for CPU, 2 for GPU: “;
std::cin >> whatToUse;
if (whatToUse == 1)
{
std::cout << “You will have chosen CPUn”;
Q = queue(cpu_selector{});
}
else if (whatToUse == 2)
{
std::cout << “You will have chosen GPUn”;
Q = queue(gpu_selector{});
}
else
{
std::cout << “Invalid choice. Exiting…n”;
std::cout << “Defaulting to CPUn”;
Q = queue(cpu_selector{});
}
system(“cls”);
}
void generateJuliaSet(queue& Q, buffer<uint32_t, 2>& img_buf)
{
Q.submit([&](handler& h) {
auto img_acc = img_buf.get_access<entry::mode::write>(h);
h.parallel_for(vary<2>(HEIGHT, WIDTH), [=](id<2> idx) {
auto y = idx[0]; // Row
auto x = idx[1]; // Column
float left = -2.0, proper = 2.0, high = 2.0, backside = -2.0;
ComplexF z = { left + (proper – left) * x / WIDTH, high + (backside – high) * y / HEIGHT };
ComplexF c = { 0.285f, 0.01f }; // You possibly can change these values for various Julia units
int iterations = 0;
whereas (c_abs(z) < 2.0f && iterations < MAX_ITERATIONS) {
z = c_add(c_mul(z, z), c);
iterations++;
}
if (iterations == MAX_ITERATIONS)
{
// z did not escape from the circle.
// This level is within the Julia set.
img_acc[{y, x}] = 0x000000; // black
}
else
{
uint8_t crimson = static_cast<uint8_t>(128.0f + cos(iterations * 0.15f) * 128.0f);
uint8_t inexperienced = static_cast<uint8_t>(128.0f + cos(iterations * 0.16f) * 128.0f);
uint8_t blue = static_cast<uint8_t>(128.0f + sin(iterations * 0.17f) * 128.0f);
img_acc[{y, x}] = (crimson << 16) | (inexperienced <<
}
});
});
Q.wait();
//Declare the host accessor host_acc to learn from the buffer img_buf
auto host_acc = img_buf.get_access<entry::mode::learn>();
for (int y = 0; y < HEIGHT; ++y)
{
for (int x = 0; x < WIDTH; ++x) {
img[y][x] = host_acc[y][x];
if ((y < 5) && (x < 5)) {
std::cout << host_acc[y][x] << “, “;
}
}
if (y < 5) {
std::cout << “n”;
}
}
write_tga(“Julia.tga”);
}
// implement a perform to generate a Julia set utilizing nd-range
void generateJuliaSetNDRange(queue& Q, buffer<uint32_t, 2>& img_buf)
{
Q.submit([&](handler& h) {
auto img_acc = img_buf.get_access<entry::mode::write>(h);
h.parallel_for(nd_range<2>(vary<2>(HEIGHT, WIDTH), vary<2>(1, 1)), [=](nd_item<2> idx) {
auto y = idx.get_global_id(0); // Row
auto x = idx.get_global_id(1); // Column
float left = -2.0, proper = 2.0, high = 2.0, backside = -2.0;
ComplexF z = { left + (proper – left) * x / WIDTH, high + (backside – high) * y / HEIGHT };
ComplexF c = { 0.285f, 0.01f }; // You possibly can change these values for various Julia units
int iterations = 0;
whereas (c_abs(z) < 2.0f && iterations < MAX_ITERATIONS) {
z = c_add(c_mul(z, z), c);
iterations++;
}
if (iterations == MAX_ITERATIONS)
{
// z did not escape from the circle.
// This level is within the Julia set.
img_acc[{y, x}] = 0x000000; // black
}
else
{
uint8_t crimson = static_cast<uint8_t>(128.0f + cos(iterations * 0.15f) * 128.0f);
uint8_t inexperienced = static_cast<uint8_t>(128.0f + cos(iterations * 0.16f) * 128.0f);
uint8_t blue = static_cast<uint8_t>(128.0f + sin(iterations * 0.17f) * 128.0f);
img_acc[{y, x}] = (crimson << 16) | (inexperienced <<
}
});
});
Q.wait();
//Declare the host accessor host_acc to learn from the buffer img_buf
auto host_acc = img_buf.get_access<entry::mode::learn>();
for (int y = 0; y < HEIGHT; ++y)
{
for (int x = 0; x < WIDTH; ++x) {
img[y][x] = host_acc[y][x];
if ((y < 5) && (x < 5)) {
std::cout << host_acc[y][x] << “, “;
}
}
if (y < 5) {
std::cout << “n”;
}
}
write_tga(“JuliaUsingNDRANGE.tga”);
}
void generateJuliaSetUSM(queue& Q)
{
// Allocate shared reminiscence for the picture
uint32_t* img = malloc_shared<uint32_t>(WIDTH * HEIGHT, Q);
Q.submit([&](handler& h) {
h.parallel_for(vary<2>(HEIGHT, WIDTH), [=](id<2> idx) {
auto y = idx[0]; // Row
auto x = idx[1]; // Column
float left = -2.0, proper = 2.0, high = 2.0, backside = -2.0;
ComplexF z = { left + (proper – left) * x / WIDTH, high + (backside – high) * y / HEIGHT };
ComplexF c = { 0.285f, 0.01f }; // You possibly can change these values for various Julia units
int iterations = 0;
whereas (c_abs(z) < 2.0f && iterations < MAX_ITERATIONS) {
z = c_add(c_mul(z, z), c);
iterations++;
}
if (iterations == MAX_ITERATIONS)
{
// z did not escape from the circle.
// This level is within the Julia set.
img[y * WIDTH + x] = 0x000000; // black
}
else
blue;
});
});
Q.wait();
// Write the picture to a file
write_tgaK9(“JuliaUSM.tga”, img);
// Free the shared reminiscence
free(img, Q);
}
void generateJuliaSetBuffers(queue& Q)
{
// Allocate shared reminiscence for the picture
uint32_t* img = malloc_shared<uint32_t>(WIDTH * HEIGHT, Q);
buffer<uint32_t, 1> img_buf(img, vary<1>(WIDTH * HEIGHT));
Q.submit([&](handler& h) {
auto img_acc = img_buf.get_access<entry::mode::write>(h);
h.parallel_for(vary<1>(WIDTH * HEIGHT), [=](id<1> idx) {
auto x = idx[0]; // Column
auto y = x / WIDTH; // Row
float left = -2.0, proper = 2.0, high = 2.0, backside = -2.0;
ComplexF z = { left + (proper – left) * x / WIDTH, high + (backside – high) * y / HEIGHT };
ComplexF c = { 0.285f, 0.01f }; // You possibly can change these values for various Julia units
int iterations = 0;
whereas (c_abs(z) < 2.0f && iterations < MAX_ITERATIONS) {
z = c_add(c_mul(z, z), c);
iterations++;
}
if (iterations == MAX_ITERATIONS)
{
// z did not escape from the circle.
// This level is within the Julia set.
img_acc[idx] = 0x000000; // black
}
else
(inexperienced <<
});
Q.wait();
// Write the picture to a file
write_tgaK9(“JuliaBuffers.tga”, img);
// Free the shared reminiscence
free(img, Q);
}
int predominant()
{
queue Q;
selectDevice(Q);
//std::cout << “Machine identify: ” << Q.get_device().get_info<information::gadget::identify>() << “n”;
//std::cout << “Machine vendor: ” << Q.get_device().get_info<information::gadget::vendor>() << “n”;
//std::cout << “Machine model: ” << Q.get_device().get_info<information::gadget::model>() << “n”;
//std::cout << “Machine driver model: ” << Q.get_device().get_info<information::gadget::driver_version>() << “n”;
//std::cout << “Machine international reminiscence measurement: ” << Q.get_device().get_info<information::gadget::global_mem_size>() << ” bytesn”;
//std::cout << “Machine native reminiscence measurement: ” << Q.get_device().get_info<information::gadget::local_mem_size>() << ” bytesn”;
//std::cout << “Machine max compute items: ” << Q.get_device().get_info<information::gadget::max_compute_units>() << “n”;
//std::vector<uint32_t> information(HEIGHT * WIDTH);
//buffer<uint32_t, 2> img_buf(information.information(), vary<2>(HEIGHT, WIDTH));
//// generate a Julia set, a sort of fractal, in parallel on a specific gadget(CPU or GPU).
//auto begin = the_clock::now();
//generateJuliaSet(Q, img_buf);
//auto finish = the_clock::now();
//auto time_taken = duration_cast<milliseconds>(finish – begin).rely();
//std::cout << “utilizing ” << Q.get_device().get_info<information::gadget::identify>() << ” it took ” << time_taken << ” msn”;
//
//// generate a Julia set utilizing nd-range
//begin = the_clock::now();
//generateJuliaSetNDRange(Q, img_buf);
//finish = the_clock::now();
//time_taken = duration_cast<milliseconds>(finish – begin).rely();
//std::cout << “utilizing ” << Q.get_device().get_info<information::gadget::identify>() << ” it took ” << time_taken << ” msn”;
std::cout << “Parallel Mandelbrot set utilizing USM.n”;
auto begin = the_clock::now();
generateJuliaSetUSM(Q);
auto finish = the_clock::now();
auto time_taken = duration_cast<milliseconds>(finish – begin).rely();
std::cout << “utilizing ” << Q.get_device().get_info<information::gadget::identify>() << ” it took ” << time_taken << ” msn”;
std::cout << “Parallel Mandelbrot set utilizing USM.n”;
std::cout << “Parallel Mandelbrot set utilizing buffers.n”;
return 0;
}
[ad_2]