1a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni/* 2a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * Copyright 2013, The Android Open Source Project 3a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * 4a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * Licensed under the Apache License, Version 2.0 (the "License"); 5a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * you may not use this file except in compliance with the License. 6a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * You may obtain a copy of the License at 7a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * 8a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * http://www.apache.org/licenses/LICENSE-2.0 9a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * 10a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * Unless required by applicable law or agreed to in writing, software 11a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * distributed under the License is distributed on an "AS IS" BASIS, 12a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * See the License for the specific language governing permissions and 14a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni * limitations under the License. 15a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni */ 16a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 17a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni#ifndef BCC_RS_SCRIPT_GROUP_FUSION_H 18a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni#define BCC_RS_SCRIPT_GROUP_FUSION_H 19a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 20a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni#include <vector> 210ab50b835805c75ad164466767c2c212f48954ccYang Ni#include <string> 22a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 23a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ninamespace llvm { 24a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Niclass Module; 25a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni} 26a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 27a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ninamespace bcc { 28a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 29a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Niclass Source; 30a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Niclass BCCContext; 31a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 32a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni/// @brief Fuse kernels 33a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni/// 340ab50b835805c75ad164466767c2c212f48954ccYang Ni/// @param Context bcc context. 350ab50b835805c75ad164466767c2c212f48954ccYang Ni/// @param sources The Sources containing the kernels. 360ab50b835805c75ad164466767c2c212f48954ccYang Ni/// @param slots The slots where the kernels are located. 370ab50b835805c75ad164466767c2c212f48954ccYang Ni/// @param fusedName 388c12d615b4ed4b1d782722a125dd1d43bc44a71bYang Ni/// @return True, if kernels are successfully fused. False, otherwise. It's up to 398c12d615b4ed4b1d782722a125dd1d43bc44a71bYang Ni/// the caller on how to deal with unsuccessful fusion. A script group can 408c12d615b4ed4b1d782722a125dd1d43bc44a71bYang Ni/// execute with either fused kernels or individual kernels. 410ab50b835805c75ad164466767c2c212f48954ccYang Nibool fuseKernels(BCCContext& Context, 420ab50b835805c75ad164466767c2c212f48954ccYang Ni const std::vector<Source *>& sources, 430ab50b835805c75ad164466767c2c212f48954ccYang Ni const std::vector<int>& slots, 440ab50b835805c75ad164466767c2c212f48954ccYang Ni const std::string& fusedName, 450ab50b835805c75ad164466767c2c212f48954ccYang Ni llvm::Module* mergedModule); 460ab50b835805c75ad164466767c2c212f48954ccYang Ni 470ab50b835805c75ad164466767c2c212f48954ccYang Nibool renameInvoke(BCCContext& Context, const Source* source, const int slot, 480ab50b835805c75ad164466767c2c212f48954ccYang Ni const std::string& newName, llvm::Module* mergedModule); 49a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni} 50a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni 51a4ded1373d7ad3e503f186e65bccf94126a0f020Yang Ni#endif /* BCC_RS_SCRIPT_GROUP_FUSION_H */ 52