pytorch  1.8.2
About: PyTorch provides Tensor computation (like NumPy) with strong GPU acceleration and Deep Neural Networks (in Python) built on a tape-based autograd system. LTS (Long Term Support) release.
  Fossies Dox: pytorch-1.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

core_overhead_benchmark.cc
Go to the documentation of this file.
1/**
2 * Copyright (c) 2016-present, Facebook, Inc.
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
17#include "benchmark/benchmark.h"
18
19#include <c10/util/Logging.h>
20
21#if defined(__GNUC__)
22#define NOINLINE __attribute__((noinline))
23#else
24#define NOINLINE
25#endif
26
27NOINLINE int call(int id) {
29 return id%2;
30}
31
33 return id%2;
34}
35
37 int id = 0;
38 while (state.KeepRunning()) {
39 for (int i = 0; i < 1000; ++i) {
40 id += 1 + call(id);
41 }
42 }
43 benchmark::DoNotOptimize(id);
44}
46
48 int id = 0;
49 while (state.KeepRunning()) {
50 for (int i = 0; i < 1000; ++i) {
51 id += 1 + call_no_logging(id);
52 }
53 }
54 benchmark::DoNotOptimize(id);
55}
57
#define C10_LOG_API_USAGE_ONCE(...)
Very lightweight logging for the first time API usage.
Definition: Logging.h:295
#define NOINLINE
Copyright (c) 2016-present, Facebook, Inc.
int call(int id)
static void BM_NoAPILogging(benchmark::State &state)
BENCHMARK_MAIN()
int call_no_logging(int id)
BENCHMARK(BM_APILogging)
static void BM_APILogging(benchmark::State &state)
benchmark::State & state