Following parallel.for loop uses data of a bitarray which is 300000 bits in length. and the data is fixed not to change. So the produced results "Count_of_Found_Pattern1" must be same no matter how many times I execute the function "check"
But, the issue is the values of "Count_of_Found_Pattern1" & "Count_of_Found_Pattern2" produce different values every time I execute the function "check" .. what have I done wrong?
when I check it using small amount of bits (about 16 bits instead of 300000) it produces good results. But, when the bitarray length is lengthier, it produces a total mess.
For Example:
1st execution --> Count_of_Found_Pattern1 = 150526 , Count_of_Found_Pattern2 = 97855
2nd execution --> Count_of_Found_Pattern1 = 45855 , Count_of_Found_Pattern2 = 187562
Regards!
But, the issue is the values of "Count_of_Found_Pattern1" & "Count_of_Found_Pattern2" produce different values every time I execute the function "check" .. what have I done wrong?
when I check it using small amount of bits (about 16 bits instead of 300000) it produces good results. But, when the bitarray length is lengthier, it produces a total mess.
For Example:
1st execution --> Count_of_Found_Pattern1 = 150526 , Count_of_Found_Pattern2 = 97855
2nd execution --> Count_of_Found_Pattern1 = 45855 , Count_of_Found_Pattern2 = 187562
Regards!
Private Function check() Dim Count_of_Found_Pattern1 As Int64 = 0 Dim Count_of_Found_Pattern2 As Int64 = 0 Dim Current_Position1, Current_Position2 As Int64 Parallel.For(0, lastbitarrayover2, Sub(countbits, loopstate) If BitArray(Current_Position1) = False And BitArray(Current_Position2) = True Then Count_of_Found_Pattern1 = Count_of_Found_Pattern1 + 1 End If If BitArray(Current_Position1) = True And BitArray(Current_Position2) = False Then Count_of_Found_Pattern2 = Count_of_Found_Pattern2 + 1 End If Current_Position1 = Current_Position1 + 2 Current_Position2 = Current_Position2 + 2 Number_of_Completed_Iterations = Number_of_Completed_Iterations + 1 End Sub) End Function
Last edited: