Hello,
furthermore I test Metal and at the moment I get an internal error 0000000e. I added the WWDC 20 Debug GPU-side error in Metal recommendation with no effect on error or more description.
What I do is using the compute command encoder to
calculate 8-bit pearson hashes over a count of 256^3 UInt array and do the follow in the Metal code
(1) first calculate over given (sorted) 3 UInts as hashA (f.e. 0,0,0 is first, 0,0,1 is second...)
(2) calculate a new Pearson hash with this 3 UInt an the hashA with result hashB
(3) calculate a newer Pearson hash with these (now) 3 Uint hashA and hashB to my final hash
(4) In 3 loops do the same 1-4 for all steps 1 to 3 to looking for the hash collisions and add 1 to a counter if the collision is found but not my 3 UInts from step 1 - this is the result I want.
The algorithm is not fine but works for is Swift implementation as single core an multi core.
But Metal leaves method in the middle of work and I see some "side" effects. For example next two parts of source code differ with typeof loop variable and hard coded array length (2. code).
This code begins with internal error 0000000e message and starts to write 99 in the 256^3 long result float array. Somewhere within the working it crash. But let the program run two times and the crash is not at the same position in loop.
Today at first run result array at 596891 did not set 0 next is set next not set and later no set,
at second run here is the 99 set up to offset 14700544 but not from offset 14700545 to end
at third run the last set was at offset 708541 in the result array all after some before are not set.
for (int maybe0 = 0; maybe0 <= 255 && runAgain; maybe0++) {
for (int maybe1 = 0; maybe1 <= 255 && runAgain; maybe1++) {
for (int maybe2 = 0; maybe2 <= 255 && runAgain; maybe2++) {
const uchar baseForHashA[] = {
(uchar) maybe0,
(uchar) maybe1,
(uchar) maybe2
};
const int anzahlElementeMaybeA = *(&baseForHashA+1)-baseForHashA;
uchar maybeHashA = 0;
for (int i=0; i<anzahlElementeMaybeA; i++) {
int locationA = (maybeHashA ^ baseForHashA[i]);
maybeHashA = WIKIPEDIA_EN_TABLE[locationA];
}
if (maybeHashA == hashA) {
const uchar baseForHashB[] = {
(uchar) maybe0,
maybeHashA,
(uchar) maybe1,
(uchar) maybe2
};
const int anzahlElementeMaybeB = *(&baseForHashB+1)-baseForHashB;
uchar maybeHashB = 0;
for (int i=0; i<anzahlElementeMaybeB; i++) {
int locationB = (maybeHashB ^ baseForHashB[i]);
maybeHashB = WIKIPEDIA_EN_TABLE[locationB];
}
const int left = maybeHashB;
const int right = hashB;
if (left == right) {
result [index] = offset +99;
return;
offset += 1;
if (
(uchar) arr1[index] == maybe0 &&
(uchar) arr2[index] == maybe1 &&
(uchar) arr3[index] == maybe2
){
result[index] = offset;
runAgain = false;
}
}
}
}
}
}
This code write 99 to the complete 256^3 long result float array
for (uchar maybe0 = 0; maybe0 <= 255 && runAgain; maybe0++) {
for (uchar maybe1 = 0; maybe1 <= 255 && runAgain; maybe1++) {
for (uchar maybe2 = 0; maybe2 <= 255 && runAgain; maybe2++) {
const uchar baseForHashA[] = {
maybe0,
maybe1,
maybe2
};
uchar maybeHashA = 0;
for (int i=0; i<3; i++) {
int locationA = (maybeHashA ^ baseForHashA[i]);
maybeHashA = WIKIPEDIA_EN_TABLE[locationA];
}
if (maybeHashA == hashA) {
const uchar baseForHashB[] = {
maybe0,
maybeHashA,
maybe1,
maybe2
};
uchar maybeHashB = 0;
for (int i=0; i<4; i++) {
int locationB = (maybeHashB ^ baseForHashB[i]);
maybeHashB = WIKIPEDIA_EN_TABLE[locationB];
}
const int left = maybeHashB;
const int right = hashB;
if (left == right) {
result [index] = offset +99;
return;
offset += 1;
if (
arr1[index] == maybe0 &&
arr2[index] == maybe1 &&
arr3[index] == maybe2
){
result[index] = offset;
runAgain = false;
}
}
}
}
}
I need only 6 lines more running Metal code. Help!!!
thx
Post
Replies
Boosts
Views
Activity
Hello,
I begin / test a little with Swift and Metal (only for compute shaders). All I see (in samples) is working with primitive datatypes but I work with struct or classes. Can I and How move data between Swift and Metal in a struct or in other words declare a kernel function with struct and used from Swift? Is somewhere an example?
I want to compute with 100+ input parameters and not much less result values for maybe more than hundred thousand times.
Thanks
Sebastian