您好,我正在尝试使用 DPC++ 并行化我的两个循环,但它给出了 LLVM 错误:SPIRV 内部错误。不知道为什么,各位大神能帮我解决一下问题吗?
char* rsa_decrypt_without_private_key(const long long* message, const unsigned long message_size, const struct public_key_class* pub)
{
struct private_key_class unknownpriv[1];
long long p, q, phi_max, e, d;
p = public_prime;
q = pub->modulus / p;
phi_max = (p - 1) * (q - 1);
e = powl(2, 8) + 1;
d = ExtEuclid(phi_max, e);
while (d < 0) {
d = d + phi_max;
}
unknownpriv->modulus = pub->modulus;
unknownpriv->exponent = d;
if (message_size % sizeof(long long) != 0) {
fprintf(stderr, "Error: message_size is not divisible by %d, so cannot be output of rsa_encrypt\n", (int)sizeof(long long));
return NULL;
}
char* decrypted = (char*) malloc(message_size / sizeof(long long));
char* temp = (char*) malloc(message_size);
if ((decrypted == NULL) || (temp == NULL)) {
fprintf(stderr, "Error: Heap allocation failed.\n");
return NULL;
}
buffer<char, 1> A(decrypted, range<1>{ message_size / sizeof(long long)});
buffer<char, 1> B(temp, range<1>{ message_size });
auto R = range<1>{ message_size / 8 };
queue z;
z.submit([&](handler& h) {
auto out = B.get_access<access::mode::write>(h);
h.parallel_for(R, [=](id<1> i) {
out[i] = rsa_modExp(message[i], unknownpriv->exponent, unknownpriv->modulus);
});
});
z.submit([&](handler& h) {
auto out = A.get_access<access::mode::write>(h);
auto in = B.get_access<access::mode::read>(h);
h.parallel_for(R, [=](id<1> i) {
out[i] = in[i];
});
});
/*
for (i = 0; i < message_size / 8; i++) {
temp[i] = rsa_modExp(message[i], unknownpriv->exponent, unknownpriv->modulus);
}
for (i = 0; i < message_size / 8; i++) {
decrypted[i] = temp[i];
}*/
free(temp);
return decrypted;
}