testCompileBullet3PgsJointSolverKernels.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #include <gtest/gtest.h>
  2. #include "Bullet3Common/b3Logging.h"
  3. #include "Bullet3Common/b3CommandLineArgs.h"
  4. #include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
  5. #include "Bullet3OpenCL/RigidBody/kernels/jointSolver.h"
  6. extern int gArgc;
  7. extern char** gArgv;
  8. namespace
  9. {
  10. struct testCompileBullet3PgsJointSolverKernels : public ::testing::Test
  11. {
  12. cl_context m_clContext;
  13. cl_device_id m_clDevice;
  14. cl_command_queue m_clQueue;
  15. char* m_clDeviceName;
  16. cl_platform_id m_platformId;
  17. testCompileBullet3PgsJointSolverKernels()
  18. :m_clDeviceName(0),
  19. m_clContext(0),
  20. m_clDevice(0),
  21. m_clQueue(0),
  22. m_platformId(0)
  23. {
  24. // You can do set-up work for each test here.
  25. b3CommandLineArgs args(gArgc,gArgv);
  26. int preferredDeviceIndex=-1;
  27. int preferredPlatformIndex = -1;
  28. bool allowCpuOpenCL = false;
  29. initCL();
  30. }
  31. virtual ~testCompileBullet3PgsJointSolverKernels()
  32. {
  33. // You can do clean-up work that doesn't throw exceptions here.
  34. exitCL();
  35. }
  36. // If the constructor and destructor are not enough for setting up
  37. // and cleaning up each test, you can define the following methods:
  38. #include "initCL.h"
  39. virtual void SetUp()
  40. {
  41. // Code here will be called immediately after the constructor (right
  42. // before each test).
  43. }
  44. virtual void TearDown()
  45. {
  46. // Code here will be called immediately after each test (right
  47. // before the destructor).
  48. }
  49. };
  50. TEST_F(testCompileBullet3PgsJointSolverKernels,solveConstraintRowsCL)
  51. {
  52. cl_int errNum=0;
  53. cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,solveConstraintRowsCL,&errNum,"",0,true);
  54. ASSERT_EQ(CL_SUCCESS,errNum);
  55. {
  56. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,solveConstraintRowsCL, "solveJointConstraintRows",&errNum,prog);
  57. ASSERT_EQ(CL_SUCCESS,errNum);
  58. ASSERT_FALSE(k==0);
  59. clReleaseKernel(k);
  60. }
  61. {
  62. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"initSolverBodies",&errNum,prog);
  63. ASSERT_EQ(CL_SUCCESS,errNum);
  64. ASSERT_FALSE(k==0);
  65. clReleaseKernel(k);
  66. }
  67. {
  68. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"getInfo1Kernel",&errNum,prog);
  69. ASSERT_EQ(CL_SUCCESS,errNum);
  70. ASSERT_FALSE(k==0);
  71. clReleaseKernel(k);
  72. }
  73. {
  74. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"initBatchConstraintsKernel",&errNum,prog);
  75. ASSERT_EQ(CL_SUCCESS,errNum);
  76. ASSERT_FALSE(k==0);
  77. clReleaseKernel(k);
  78. }
  79. {
  80. cl_kernel k= b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"getInfo2Kernel",&errNum,prog);
  81. ASSERT_EQ(CL_SUCCESS,errNum);
  82. ASSERT_FALSE(k==0);
  83. clReleaseKernel(k);
  84. }
  85. {
  86. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"writeBackVelocitiesKernel",&errNum,prog);
  87. ASSERT_EQ(CL_SUCCESS,errNum);
  88. ASSERT_FALSE(k==0);
  89. clReleaseKernel(k);
  90. }
  91. {
  92. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext,m_clDevice,solveConstraintRowsCL,"breakViolatedConstraintsKernel",&errNum,prog);
  93. ASSERT_EQ(CL_SUCCESS,errNum);
  94. ASSERT_FALSE(k==0);
  95. clReleaseKernel(k);
  96. }
  97. clReleaseProgram(prog);
  98. }
  99. };