README 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //========================================================================================================================================================================================================200
  2. // UPDATE
  3. //========================================================================================================================================================================================================200
  4. // Lukasz G. Szafaryn 24 JAN 09
  5. //========================================================================================================================================================================================================200
  6. // DESCRIPTION
  7. //========================================================================================================================================================================================================200
  8. // Myocyte application models cardiac myocyte (heart muscle cell) and simulates its behavior according to the work by Saucerman and Bers [8]. The model integrates
  9. // cardiac myocyte electrical activity with the calcineurin pathway, which is a key aspect of the development of heart failure. The model spans large number of temporal
  10. // scales to reflect how changes in heart rate as observed during exercise or stress contribute to calcineurin pathway activation, which ultimately leads to the expression
  11. // of numerous genes that remodel the heart’s structure. It can be used to identify potential therapeutic targets that may be useful for the treatment of heart failure.
  12. // Biochemical reactions, ion transport and electrical activity in the cell are modeled with 91 ordinary differential equations (ODEs) that are determined by more than 200
  13. // experimentally validated parameters. The model is simulated by solving this group of ODEs for a specified time interval. The process of ODE solving is based on the
  14. // causal relationship between values of ODEs at different time steps, thus it is mostly sequential. At every dynamically determined time step, the solver evaluates the
  15. // model consisting of a set of 91 ODEs and 480 supporting equations to determine behavior of the system at that particular time instance. If evaluation results are not
  16. // within the expected tolerance at a given time step (usually as a result of incorrect determination of the time step), another calculation attempt is made at a modified
  17. // (usually reduced) time step. Since the ODEs are stiff (exhibit fast rate of change within short time intervals), they need to be simulated at small time scales with an
  18. // adaptive step size solver.
  19. // 1) The original version of the current solver code was obtained from: Mathematics Source Library (http://mymathlib.webtrellis.net/index.html). The solver has been
  20. // somewhat modified to tailor it to our needs. However, it can be reverted back to original form or modified to suit other simulations.
  21. // 2) This solver and particular solving algorithm used with it (embedded_fehlberg_7_8) were adapted to work with a set of equations, not just one like in original version.
  22. // 3) In order for solver to provide deterministic number of steps (needed for particular amount of memore previousely allocated for results), every next step is
  23. // incremented by 1 time unit (h_init).
  24. // 4) Function assumes that simulation starts at some point of time (whatever time the initial values are provided for) and runs for the number of miliseconds (xmax)
  25. // specified by the uses as a parameter on command line.
  26. // 5) The appropriate amount of memory is previousely allocated for that range (y).
  27. // 6) This setup in 3) - 5) allows solver to adjust the step ony from current time instance to current time instance + 0.9. The next time instance is current time instance + 1;
  28. // 7) The original solver cannot handle cases when equations return NAN and INF values due to discontinuities and /0. That is why equations provided by user need to
  29. // make sure that no NAN and INF are returned.
  30. // 8) Application reads initial data and parameters from text files: y.txt and params.txt respectively that need to be located in the same folder as source files.
  31. // For simplicity and testing purposes only, when multiple number of simulation instances is specified, application still reads initial data from the same input files. That
  32. // can be modified in this source code.
  33. //========================================================================================================================================================================================================200
  34. // IMPLEMENTATION-SPECIFIC DESCRIPTION (CUDA)
  35. //========================================================================================================================================================================================================200
  36. // This is the CUDA version of Myocyte code.
  37. // The original single-threaded code was written in MATLAB and used MATLAB ode45 ODE solver. In the process of accelerating this code, we arrived with the
  38. // intermediate versions that used single-threaded Sundials CVODE solver which evaluated model parallelized with CUDA at each time step. In order to convert entire
  39. // solver to CUDA code (to remove some of the operational overheads such as kernel launches and data transfer in CUDA) we used a simpler solver, from Mathematics
  40. // Source Library, and tailored it to our needs. The parallelism in the cardiac myocyte model is on a very fine-grained level, close to that of ILP, therefore it is very hard
  41. // to exploit as DLP or TLB in CUDA code. We were able to divide the model into 4 individual groups that run in parallel. However, even that is not enough work to
  42. // compensate for some of the CUDA thread launch and data transfer overheads which resulted in performance worse than that of single-threaded C code. Speedup in
  43. // this code could be achieved only if a customizable accelerator such as FPGA was used for evaluation of the model itself. We also approached the application from
  44. // another angle and allowed it to run several concurrent simulations, thus turning it into an embarrassingly parallel problem. This version of the code is also useful for
  45. // scientists who want to run the same simulation with different sets of input parameters. Speedup achieved with CUDA code is variable on the other hand. It depends on
  46. // the number of concurrent simulations and it saturates around 300 simulations with the speedup of about 10x.
  47. // Speedup numbers reported in the description of this application were obtained on the machine with: Intel Quad Core CPU, 4GB of RAM, Nvidia GTX280 GPU.
  48. // 1) When running with parallelization inside each simulation instance (value of 3rd command line parameter equal to 0), performance is bad because:
  49. // a) underutilization of GPU (only 1 out of 32 threads in each block)
  50. // b) significant CPU-GPU memory copy overhead
  51. // c) kernel launch overhead (kernel needs to be finished every time model is evaluated as it is the only way to synchronize threads in different blocks)
  52. // 2) When running with parallelization across simulation instances, code gets continues speedup with the increasing number of simulation insances which saturates
  53. // around 240 instances on GTX280 (roughly corresponding to the number of multiprocessorsXprocessors in GTX280), with the speedup of around 10x compared
  54. // to serial C version of code. Limited performance is explained mainly by:
  55. // a) significant CPU-GPU memory copy overhead
  56. // b) increasingly uncoalesced memory accesses with the increasing number of workloads
  57. // c) lack of cache compared to CPU, or no use of shared memory to compensate
  58. // d) frequency of GPU shader being lower than that of CPU core
  59. // 3) GPU version has an issue with memory allocation that has not been resolved yet. For certain simulation ranges memory allocation fails, or pointers incorrectly overlap
  60. // causeing value trashing.
  61. // The following are the command parameters to the application:
  62. // 1) Simulation time interval which is the number of miliseconds to simulate. Needs to be integer > 0
  63. // Example:
  64. // ./a.out -time 100
  65. //========================================================================================================================================================================================================200
  66. // END
  67. //========================================================================================================================================================================================================200