1 /* 2 * Copyright (c) 2024, 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 #pragma once 27 #include <iostream> 28 struct BasicConfig { 29 // These must sync with hat/backend/ffi/Mode.java 30 // Bits 0-3 select platform id 0..5 31 // Bits 4-7 select device id 0..15 32 static constexpr int START_BIT_IDX = 16; 33 static constexpr int MINIMIZE_COPIES_BIT = 1 << START_BIT_IDX; 34 static constexpr int TRACE_BIT = 1 << 17; 35 static constexpr int PROFILE_BIT = 1 << 18; 36 static constexpr int SHOW_CODE_BIT = 1 << 19; 37 static constexpr int SHOW_KERNEL_MODEL_BIT = 1 << 20; 38 static constexpr int SHOW_COMPUTE_MODEL_BIT = 1 << 21; 39 static constexpr int INFO_BIT = 1 << 22; 40 static constexpr int TRACE_COPIES_BIT = 1 << 23; 41 static constexpr int TRACE_SKIPPED_COPIES_BIT = 1 << 24; 42 static constexpr int TRACE_ENQUEUES_BIT = 1 << 25; 43 static constexpr int TRACE_CALLS_BIT = 1 << 26; 44 static constexpr int SHOW_WHY_BIT = 1 << 27; 45 static constexpr int SHOW_STATE_BIT = 1 << 28; 46 static constexpr int PTX_BIT = 1 << 29; 47 static constexpr int INTERPRET_BIT = 1 << 30; 48 static constexpr int END_BIT_IDX = 31; 49 50 const static char *bitNames[]; // See below for out of line definition 51 int configBits; 52 bool minimizeCopies; 53 bool alwaysCopy; 54 bool trace; 55 bool profile; 56 bool showCode; 57 bool info; 58 bool traceCopies; 59 bool traceSkippedCopies; 60 bool traceEnqueues; 61 bool traceCalls; 62 bool showWhy; 63 bool showState; 64 bool ptx; 65 bool interpret; 66 int platform; //0..15 67 int device; //0..15 68 explicit BasicConfig(int configBits): 69 configBits(configBits), 70 minimizeCopies((configBits & MINIMIZE_COPIES_BIT) == MINIMIZE_COPIES_BIT), 71 alwaysCopy(!minimizeCopies), 72 trace((configBits & TRACE_BIT) == TRACE_BIT), 73 traceCopies((configBits & TRACE_COPIES_BIT) == TRACE_COPIES_BIT), 74 traceEnqueues((configBits & TRACE_ENQUEUES_BIT) == TRACE_ENQUEUES_BIT), 75 traceCalls((configBits & TRACE_CALLS_BIT) == TRACE_CALLS_BIT), 76 traceSkippedCopies((configBits & TRACE_SKIPPED_COPIES_BIT) == TRACE_SKIPPED_COPIES_BIT), 77 info((configBits & INFO_BIT) == INFO_BIT), 78 showCode((configBits & SHOW_CODE_BIT) == SHOW_CODE_BIT), 79 profile((configBits & PROFILE_BIT) == PROFILE_BIT), 80 showWhy((configBits & SHOW_WHY_BIT) == SHOW_WHY_BIT), 81 showState((configBits & SHOW_STATE_BIT) == SHOW_STATE_BIT), 82 ptx((configBits & PTX_BIT) == PTX_BIT), 83 interpret((configBits & INTERPRET_BIT) == INTERPRET_BIT), 84 platform(configBits & 0xf), 85 device((configBits & 0xf0) >> 4) { 86 if (info) { 87 std::cout << "native showCode " << showCode << std::endl; 88 std::cout << "native info " << info << std::endl; 89 std::cout << "native minimizeCopies " << minimizeCopies << std::endl; 90 std::cout << "native alwaysCopy " << alwaysCopy << std::endl; 91 std::cout << "native trace " << trace << std::endl; 92 std::cout << "native traceSkippedCopies " << traceSkippedCopies << std::endl; 93 std::cout << "native traceCalls " << traceCalls << std::endl; 94 std::cout << "native traceCopies " << traceCopies << std::endl; 95 std::cout << "native traceEnqueues " << traceEnqueues << std::endl; 96 std::cout << "native profile " << profile << std::endl; 97 std::cout << "native showWhy " << showWhy << std::endl; 98 std::cout << "native showState " << showState << std::endl; 99 std::cout << "native ptx " << ptx << std::endl; 100 std::cout << "native interpret " << interpret << std::endl; 101 std::cout << "native platform " << platform << std::endl; 102 std::cout << "native device " << device << std::endl; 103 } 104 } 105 106 virtual ~BasicConfig()= default; 107 }; 108 109 #ifdef shared_cpp 110 const char *BasicConfig::bitNames[] = { 111 "MINIMIZE_COPIES", 112 "TRACE", 113 "PROFILE", 114 "SHOW_CODE", 115 "SHOW_KERNEL_MODEL", 116 "SHOW_COMPUTE_MODEL", 117 "INFO", 118 "TRACE_COPIES", 119 "TRACE_SKIPPED_COPIES", 120 "TRACE_ENQUEUES", 121 "TRACE_CALLS", 122 "SHOW_WHY_BIT", 123 "USE_STATE_BIT", 124 "SHOW_STATE_BIT" 125 }; 126 #endif