//===-- metal_compute ------------------------------------------------------===//
// Copyright (c) 2014 Apple Inc. All rights reserved
//===----------------------------------------------------------------------===//

#ifndef __METAL_COMPUTE
#define __METAL_COMPUTE

#define _AIR_MEM_SCOPE_WORK_GROUP 0x2
#define _AIR_MEM_SCOPE_DEVICE 0x3

namespace metal {
  // 5.8 Compute Functions

  // 5.8.1 Work-Group Synchronization Functions
  enum class mem_flags { mem_none = 0x0, 
                         mem_device = 0x1,
                         mem_threadgroup = 0x2,
                         mem_device_and_threadgroup = mem_device |  mem_threadgroup};

  [[no_duplicate]] METAL_INTERNAL void _air_wg_barrier(mem_flags flags, int scope = _AIR_MEM_SCOPE_WORK_GROUP) __asm("air.wg.barrier");
  [[no_duplicate]] METAL_FUNC void threadgroup_barrier(mem_flags flags) {
    return _air_wg_barrier(flags);
  }
} // namespace metal

#endif // __METAL_COMPUTE
