File: alloc.cpp

package info (click to toggle)
embree 4.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 99,492 kB
  • sloc: cpp: 224,036; xml: 40,944; ansic: 2,731; python: 812; sh: 639; makefile: 228; csh: 42
file content (51 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "alloc.h"

////////////////////////////////////////////////////////////////////////////////
/// All Platforms
////////////////////////////////////////////////////////////////////////////////
  
namespace embree
{
#if defined(EMBREE_SYCL_SUPPORT)
  
  __thread sycl::context* tls_context = nullptr;
  __thread sycl::device* tls_device = nullptr;
  
  void enableUSMAllocTutorial(sycl::context* context, sycl::device* device)
  {
    tls_context = context;
    tls_device = device;
  }

  void disableUSMAllocTutorial()
  {
    tls_context = nullptr;
    tls_device = nullptr;
  }

#endif

  void* alignedUSMMalloc(size_t size, size_t align, EmbreeUSMMode mode)
  {
#if defined(EMBREE_SYCL_SUPPORT)
    if (tls_context)
      return alignedSYCLMalloc(tls_context,tls_device,size,align,mode);
    else
#endif
      return alignedMalloc(size,align);
  }

  void alignedUSMFree(void* ptr)
  {
#if defined(EMBREE_SYCL_SUPPORT)
    if (tls_context)
      return alignedSYCLFree(tls_context,ptr);
    else
#endif
      return alignedFree(ptr);
  }

}