kernel.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2011-2013 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* CPU kernel entry points */
  17. /* On x86-64, we can assume SSE2, so avoid the extra kernel and compile this
  18. * one with SSE2 intrinsics.
  19. */
  20. #if defined(__x86_64__) || defined(_M_X64)
  21. # define __KERNEL_SSE2__
  22. #endif
  23. /* When building kernel for native machine detect kernel features from the flags
  24. * set by compiler.
  25. */
  26. #ifdef WITH_KERNEL_NATIVE
  27. # ifdef __SSE2__
  28. # ifndef __KERNEL_SSE2__
  29. # define __KERNEL_SSE2__
  30. # endif
  31. # endif
  32. # ifdef __SSE3__
  33. # define __KERNEL_SSE3__
  34. # endif
  35. # ifdef __SSSE3__
  36. # define __KERNEL_SSSE3__
  37. # endif
  38. # ifdef __SSE4_1__
  39. # define __KERNEL_SSE41__
  40. # endif
  41. # ifdef __AVX__
  42. # define __KERNEL_SSE__
  43. # define __KERNEL_AVX__
  44. # endif
  45. # ifdef __AVX2__
  46. # define __KERNEL_SSE__
  47. # define __KERNEL_AVX2__
  48. # endif
  49. #endif
  50. /* quiet unused define warnings */
  51. #if defined(__KERNEL_SSE2__)
  52. /* do nothing */
  53. #endif
  54. #include "kernel/kernel.h"
  55. #define KERNEL_ARCH cpu
  56. #include "kernel/kernels/cpu/kernel_cpu_impl.h"
  57. CCL_NAMESPACE_BEGIN
  58. /* Memory Copy */
  59. void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size)
  60. {
  61. if (strcmp(name, "__data") == 0)
  62. memcpy(&kg->__data, host, size);
  63. else
  64. assert(0);
  65. }
  66. void kernel_tex_copy(KernelGlobals *kg, const char *name, void *mem, size_t size)
  67. {
  68. if (0) {
  69. }
  70. #define KERNEL_TEX(type, tname) \
  71. else if (strcmp(name, #tname) == 0) \
  72. { \
  73. kg->tname.data = (type *)mem; \
  74. kg->tname.width = size; \
  75. }
  76. #include "kernel/kernel_textures.h"
  77. else {
  78. assert(0);
  79. }
  80. }
  81. CCL_NAMESPACE_END