cnstream_common.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*************************************************************************
  2. * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  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. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #ifndef CNSTREAM_COMMON_HPP_
  21. #define CNSTREAM_COMMON_HPP_
  22. #include <atomic>
  23. #include <mutex>
  24. #include <sstream>
  25. #include <string>
  26. #include <vector>
  27. #include "private/cnstream_common_pri.hpp"
  28. namespace cnstream {
  29. // Group:Framework Function
  30. /*!
  31. * @brief Gets the number of modules that a pipeline is able to hold.
  32. *
  33. * @return The maximum modules of a pipeline can own.
  34. */
  35. uint32_t GetMaxModuleNumber();
  36. // Group:Framework Function
  37. /*!
  38. * @brief Gets the number of streams that a pipeline can hold, regardless of the limitation of hardware resources.
  39. *
  40. * @return Returns the value of `MAX_STREAM_NUM`.
  41. *
  42. * @note The factual stream number that a pipeline can process is always subject to hardware resources, no more than
  43. * `MAX_STREAM_NUM`.
  44. */
  45. uint32_t GetMaxStreamNumber();
  46. } // namespace cnstream
  47. #ifndef ROUND_UP
  48. #define ROUND_UP(addr, boundary) (((uint64_t)(addr) + (boundary)-1) & ~((boundary)-1))
  49. #endif
  50. #ifndef ROUND_DOWN
  51. #define ROUND_DOWN(addr, boundary) ((uint64_t)(addr) & ~((boundary)-1))
  52. #endif
  53. #endif // CNSTREAM_COMMON_HPP_