1 /*
  2 * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
  3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4 *
  5 * This code is free software; you can redistribute it and/or modify it
  6 * under the terms of the GNU General Public License version 2 only, as
  7 * published by the Free Software Foundation.  Oracle designates this
  8 * particular file as subject to the "Classpath" exception as provided
  9 * by Oracle in the LICENSE file that accompanied this code.
 10 *
 11 * This code is distributed in the hope that it will be useful, but WITHOUT
 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14 * version 2 for more details (a copy is included in the LICENSE file that
 15 * accompanied this code).
 16 *
 17 * You should have received a copy of the GNU General Public License version
 18 * 2 along with this work; if not, write to the Free Software Foundation,
 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20 *
 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22 * or visit www.oracle.com if you need additional information or have any
 23 * questions.
 24 */
 25 /*
 26 You probably should not edit this this file!!!
 27 It was auto generated 2026-01-08 12:22:32.577 by hat.FFIConfigCreator
 28 */
 29 #pragma once
 30 
 31 #include <iostream>
 32 
 33 struct BasicConfig{
 34     static constexpr int MINIMIZE_COPIES_BIT              = 1<<0x8;
 35     static constexpr int TRACE_BIT                        = 1<<0x9;
 36     static constexpr int PROFILE_BIT                      = 1<<0xa;
 37     static constexpr int SHOW_CODE_BIT                    = 1<<0xb;
 38     static constexpr int SHOW_KERNEL_MODEL_BIT            = 1<<0xc;
 39     static constexpr int SHOW_COMPUTE_MODEL_BIT           = 1<<0xd;
 40     static constexpr int SHOW_DEVICE_INFO_BIT             = 1<<0xe;
 41     static constexpr int INFO_BIT                         = 1<<0xf;
 42     static constexpr int WARN_BIT                         = 1<<0x10;
 43     static constexpr int UNIT_BIT                         = 1<<0x11;
 44     static constexpr int TRACE_COPIES_BIT                 = 1<<0x12;
 45     static constexpr int TRACE_SKIPPED_COPIES_BIT         = 1<<0x13;
 46     static constexpr int TRACE_ENQUEUES_BIT               = 1<<0x14;
 47     static constexpr int TRACE_CALLS_BIT                  = 1<<0x15;
 48     static constexpr int SHOW_WHY_BIT                     = 1<<0x16;
 49     static constexpr int SHOW_STATE_BIT                   = 1<<0x17;
 50     static constexpr int PTX_BIT                          = 1<<0x18;
 51     static constexpr int INTERPRET_BIT                    = 1<<0x19;
 52     static constexpr int HEADLESS_BIT                     = 1<<0x1a;
 53     static constexpr int SHOW_LOWERED_KERNEL_MODEL_BIT    = 1<<0x1b;
 54     static constexpr int SHOW_COMPILATION_PHASES_BIT      = 1<<0x1c;
 55     static constexpr int PROFILE_CUDA_KERNEL_BIT          = 1<<0x1d;
 56     static constexpr int SHOW_COMPUTE_MODEL_JAVA_CODE_BIT = 1<<0x1e;
 57     const static char *bitNames[]; // See below for initialization
 58     const static char *bitDescriptions[]; // See below for initialization
 59     int configBits;
 60     bool minimizeCopies;
 61     bool trace;
 62     bool profile;
 63     bool showCode;
 64     bool showKernelModel;
 65     bool showComputeModel;
 66     bool showDeviceInfo;
 67     bool info;
 68     bool warn;
 69     bool unit;
 70     bool traceCopies;
 71     bool traceSkippedCopies;
 72     bool traceEnqueues;
 73     bool traceCalls;
 74     bool showWhy;
 75     bool showState;
 76     bool ptx;
 77     bool interpret;
 78     bool headless;
 79     bool showLoweredKernelModel;
 80     bool showCompilationPhases;
 81     bool profileCudaKernel;
 82     bool showComputeModelJavaCode;
 83     int platform;
 84     int device;
 85     bool alwaysCopy;
 86     explicit BasicConfig(int configBits):
 87         configBits(configBits),
 88         minimizeCopies((configBits & MINIMIZE_COPIES_BIT)==MINIMIZE_COPIES_BIT),
 89         trace((configBits & TRACE_BIT)==TRACE_BIT),
 90         profile((configBits & PROFILE_BIT)==PROFILE_BIT),
 91         showCode((configBits & SHOW_CODE_BIT)==SHOW_CODE_BIT),
 92         showKernelModel((configBits & SHOW_KERNEL_MODEL_BIT)==SHOW_KERNEL_MODEL_BIT),
 93         showComputeModel((configBits & SHOW_COMPUTE_MODEL_BIT)==SHOW_COMPUTE_MODEL_BIT),
 94         showDeviceInfo((configBits & SHOW_DEVICE_INFO_BIT)==SHOW_DEVICE_INFO_BIT),
 95         info((configBits & INFO_BIT)==INFO_BIT),
 96         warn((configBits & WARN_BIT)==WARN_BIT),
 97         unit((configBits & UNIT_BIT)==UNIT_BIT),
 98         traceCopies((configBits & TRACE_COPIES_BIT)==TRACE_COPIES_BIT),
 99         traceSkippedCopies((configBits & TRACE_SKIPPED_COPIES_BIT)==TRACE_SKIPPED_COPIES_BIT),
100         traceEnqueues((configBits & TRACE_ENQUEUES_BIT)==TRACE_ENQUEUES_BIT),
101         traceCalls((configBits & TRACE_CALLS_BIT)==TRACE_CALLS_BIT),
102         showWhy((configBits & SHOW_WHY_BIT)==SHOW_WHY_BIT),
103         showState((configBits & SHOW_STATE_BIT)==SHOW_STATE_BIT),
104         ptx((configBits & PTX_BIT)==PTX_BIT),
105         interpret((configBits & INTERPRET_BIT)==INTERPRET_BIT),
106         headless((configBits & HEADLESS_BIT)==HEADLESS_BIT),
107         showLoweredKernelModel((configBits & SHOW_LOWERED_KERNEL_MODEL_BIT)==SHOW_LOWERED_KERNEL_MODEL_BIT),
108         showCompilationPhases((configBits & SHOW_COMPILATION_PHASES_BIT)==SHOW_COMPILATION_PHASES_BIT),
109         profileCudaKernel((configBits & PROFILE_CUDA_KERNEL_BIT)==PROFILE_CUDA_KERNEL_BIT),
110         showComputeModelJavaCode((configBits & SHOW_COMPUTE_MODEL_JAVA_CODE_BIT)==SHOW_COMPUTE_MODEL_JAVA_CODE_BIT),
111         platform(configBits & 0xf),
112         alwaysCopy(!minimizeCopies),
113         device((configBits & 0xf0) >> 4){
114             if(showDeviceInfo){
115                 std::cout << "native minimizeCopies " << minimizeCopies << std::endl;
116                 std::cout << "native trace " << trace << std::endl;
117                 std::cout << "native profile " << profile << std::endl;
118                 std::cout << "native showCode " << showCode << std::endl;
119                 std::cout << "native showKernelModel " << showKernelModel << std::endl;
120                 std::cout << "native showComputeModel " << showComputeModel << std::endl;
121                 std::cout << "native showDeviceInfo " << showDeviceInfo << std::endl;
122                 std::cout << "native info " << info << std::endl;
123                 std::cout << "native warn " << warn << std::endl;
124                 std::cout << "native unit " << unit << std::endl;
125                 std::cout << "native traceCopies " << traceCopies << std::endl;
126                 std::cout << "native traceSkippedCopies " << traceSkippedCopies << std::endl;
127                 std::cout << "native traceEnqueues " << traceEnqueues << std::endl;
128                 std::cout << "native traceCalls " << traceCalls << std::endl;
129                 std::cout << "native showWhy " << showWhy << std::endl;
130                 std::cout << "native showState " << showState << std::endl;
131                 std::cout << "native ptx " << ptx << std::endl;
132                 std::cout << "native interpret " << interpret << std::endl;
133                 std::cout << "native headless " << headless << std::endl;
134                 std::cout << "native showLoweredKernelModel " << showLoweredKernelModel << std::endl;
135                 std::cout << "native showCompilationPhases " << showCompilationPhases << std::endl;
136                 std::cout << "native profileCudaKernel " << profileCudaKernel << std::endl;
137                 std::cout << "native showComputeModelJavaCode " << showComputeModelJavaCode << std::endl;
138                 std::cout << "native platform " << platform << std::endl;
139                 std::cout << "native device " << device << std::endl;
140             }
141         }
142     virtual ~BasicConfig()= default;
143 };
144 
145 #ifdef shared_cpp
146 const char *BasicConfig::bitNames[]={
147     "MINIMIZE_COPIES_BIT",
148     "TRACE_BIT",
149     "PROFILE_BIT",
150     "SHOW_CODE_BIT",
151     "SHOW_KERNEL_MODEL_BIT",
152     "SHOW_COMPUTE_MODEL_BIT",
153     "SHOW_DEVICE_INFO_BIT",
154     "INFO_BIT",
155     "WARN_BIT",
156     "UNIT_BIT",
157     "TRACE_COPIES_BIT",
158     "TRACE_SKIPPED_COPIES_BIT",
159     "TRACE_ENQUEUES_BIT",
160     "TRACE_CALLS_BIT",
161     "SHOW_WHY_BIT",
162     "SHOW_STATE_BIT",
163     "PTX_BIT",
164     "INTERPRET_BIT",
165     "HEADLESS_BIT",
166     "SHOW_LOWERED_KERNEL_MODEL_BIT",
167     "SHOW_COMPILATION_PHASES_BIT",
168     "PROFILE_CUDA_KERNEL_BIT",
169     "SHOW_COMPUTE_MODEL_JAVA_CODE_BIT",
170 };
171 const char *BasicConfig::bitDescriptions[]={
172     "FFI ONLY Try to minimize copies",
173     "FFI ONLY trace code",
174     "FFI ONLY Turn on profiling",
175     "Show generated code (PTX/OpenCL/CUDA)",
176     "Show (via OpWriter) Kernel Model",
177     "Show (via OpWriter) Compute Model",
178     "FFI show platform and device info",
179     "INFO level logging",
180     "WARN(ing) level logging ",
181     "UNIT test level logging  ",
182     "FFI ONLY trace copies",
183     "FFI ONLY Trace skipped copies (see MINIMIZE_COPIES) ",
184     "FFI ONLY trace enqueued tasks",
185     "FFI ONLY trace calls (enter/leave)",
186     "FFI ONLY show why we decided to copy buffer (H to D)",
187     "Show iface buffer state changes",
188     "FFI (NVIDIA) ONLY pass PTX rather than C99 CUDA code",
189     "Interpret the code model rather than converting to bytecode",
190     "Don't show UI",
191     "Show (via OpWriter) Lowered Kernel Model",
192     "Show HAT compilation phases",
193     "Add -lineinfo to CUDA kernel compilation for profiling and debugging",
194     "Show java code view of compute model",
195 };
196 #endif