CPU vs GPU Floyd Warshall Test

Floyd Warshall is a min path algorithm,  https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm that can calculate the optimal distance between any two nodes in a graph. 

Because of the way it works is easy to be translated in a parallel implementation that can run on a GPU using CUDA. 

How the tests where performed. 

  • For each test a random graph is generated with a predefined number of nodes and stored in a array, this makes it easier to reference the data from the kernel (the code that is executed on the GPU).
  • The kernel is executed once for each node (basically the outer loop from the algorithm)
  • The iterative version is executed
  • The results of both version are compared to be sure are returning the same values. 
  • A test is executed multiple times to have an idea of the running time variance. 

Hardware used:

Below are the results with random graphs having between 500 and 5000 nodes. 


 

 Results:

#nodes CPU TIME GPU TIME
10000.7512530.12836
10000.7498880.124435
10000.7590520.125294
15002.6441430.316551
15002.6397540.331018
15002.8389660.328152
20006.8419110.701491
20007.0354390.697618
20006.9232380.708921
250013.4689291.389693
250012.799551.377885
250013.0124481.372046
300021.8331332.219689
300021.9172282.231695
300022.021132.232096
350034.555233.341517
350034.3926553.342961
350034.9842483.343004
400051.3952594.92573
400050.192924.926259
400051.3758574.92464
450073.018857.136843
450070.6252457.134519
450070.2819927.131598
500098.1940369.573494
500096.3407449.572075
500097.6594629.573266


Comments