Skip to content

Commit

Permalink
Auto clang format (#74)
Browse files Browse the repository at this point in the history
* add automated clang formatter

* Automated clang-format

* use /bin/bash and add print

* use default checkout ref

* Format only after tests are success

* Run CI on merge group

---------

Co-authored-by: barnes88 <[email protected]>
Co-authored-by: JRPAN <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent 55419d7 commit e1afc53
Show file tree
Hide file tree
Showing 33 changed files with 2,694 additions and 2,309 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ name: Short-Tests-CMake
on:
# Triggers the workflow on push or pull request events but only for the mydev branch
push:
branches-ignore:
- "gh-readonly-queue**"
merge_group:
pull_request:

# Allows you to run this workflow manually from the Actions tab
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ name: Short-Tests
on:
# Triggers the workflow on push or pull request events but only for the mydev branch
push:
branches-ignore:
- "gh-readonly-queue**"
merge_group:
pull_request:

# Allows you to run this workflow manually from the Actions tab
Expand Down Expand Up @@ -82,3 +85,26 @@ jobs:
- uses: actions/checkout@v4
- name: Run Simulation
run: /bin/bash $GITHUB_WORKSPACE/short-tests.sh
format-code:
runs-on: ubuntu-latest
needs: [build-TITANV, build-TITANV-LOCALXBAR, build-QV100, build-2060, build-3070]
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v4
# Other steps that change files in the repository go here
#
- name: Run clang-format
run: |
sudo apt-get install -y clang-format
/bin/bash ./format-code.sh
- uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Automated clang-format
# Optional. Option used by `git-status` to determine if the repository is
# dirty. See https://git-scm.com/docs/git-status#_options
status_options: '--untracked-files=no'
1 change: 1 addition & 0 deletions format-code.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This bash script formats GPGPU-Sim using clang-format
THIS_DIR="$( cd "$( dirname "$BASH_SOURCE" )" && pwd )"
echo "Running clang-format on $THIS_DIR"
clang-format -i ${THIS_DIR}/libcuda/*.h
clang-format -i ${THIS_DIR}/libcuda/*.cc
clang-format -i ${THIS_DIR}/src/*.h
Expand Down
16 changes: 8 additions & 8 deletions libcuda/cuda_runtime_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@
#if (CUDART_VERSION < 8000)
#include "__cudaFatFormat.h"
#endif
#include "gpgpu_context.h"
#include "cuda_api_object.h"
#include "../src/gpgpu-sim/gpu-sim.h"
#include "../src/cuda-sim/ptx_loader.h"
#include "../src/abstract_hardware_model.h"
#include "../src/cuda-sim/cuda-sim.h"
#include "../src/cuda-sim/ptx_ir.h"
#include "../src/cuda-sim/ptx_loader.h"
#include "../src/cuda-sim/ptx_parser.h"
#include "../src/gpgpu-sim/gpu-sim.h"
#include "../src/gpgpusim_entrypoint.h"
#include "../src/stream_manager.h"
#include "../src/abstract_hardware_model.h"
#include "cuda_api_object.h"
#include "gpgpu_context.h"

#include <pthread.h>
#include <semaphore.h>
Expand Down Expand Up @@ -464,7 +464,7 @@ static int get_app_cuda_version() {
" | grep libcudart.so | sed 's/.*libcudart.so.\\(.*\\) =>.*/\\1/' > " +
fname;
int res = system(app_cuda_version_command.c_str());
if(res == -1){
if (res == -1) {
printf("Error - Cannot detect the app's CUDA version.\n");
exit(1);
}
Expand Down Expand Up @@ -3239,8 +3239,8 @@ char *readfile(const std::string filename) {
// allocate and copy the entire ptx
char *ret = (char *)malloc((filesize + 1) * sizeof(char));
int num = fread(ret, 1, filesize, fp);
if(num == 0){
std::cout << "ERROR: Could not read data from file %s\n"
if (num == 0) {
std::cout << "ERROR: Could not read data from file %s\n"
<< filename << std::endl;
assert(0);
}
Expand Down
20 changes: 10 additions & 10 deletions src/abstract_hardware_model.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Inderpreet Singh, Timothy Rogers, Vijay Kandiah, Nikos Hardavellas,
// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
// The University of British Columbia, Northwestern University, Purdue University
// All rights reserved.
// Copyright (c) 2009-2021, Tor M. Aamodt, Inderpreet Singh, Timothy Rogers,
// Vijay Kandiah, Nikos Hardavellas, Mahmoud Khairy, Junrui Pan, Timothy G.
// Rogers The University of British Columbia, Northwestern University, Purdue
// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// 1. Redistributions of source code must retain the above copyright notice,
// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
// 3. Neither the names of The University of British Columbia, Northwestern
// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
Expand All @@ -28,7 +29,6 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.


#include "abstract_hardware_model.h"
#include <sys/stat.h>
#include <algorithm>
Expand Down Expand Up @@ -284,16 +284,16 @@ void warp_inst_t::broadcast_barrier_reduction(
void warp_inst_t::generate_mem_accesses() {
if (empty() || op == MEMORY_BARRIER_OP || m_mem_accesses_created) return;
if (!((op == LOAD_OP) || (op == TENSOR_CORE_LOAD_OP) || (op == STORE_OP) ||
(op == TENSOR_CORE_STORE_OP) ))
(op == TENSOR_CORE_STORE_OP)))
return;
if (m_warp_active_mask.count() == 0) return; // predicated off

const size_t starting_queue_size = m_accessq.size();

assert(is_load() || is_store());

//if((space.get_type() != tex_space) && (space.get_type() != const_space))
assert(m_per_scalar_thread_valid); // need address information per thread
// if((space.get_type() != tex_space) && (space.get_type() != const_space))
assert(m_per_scalar_thread_valid); // need address information per thread

bool is_write = is_store();

Expand Down
81 changes: 43 additions & 38 deletions src/abstract_hardware_model.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Inderpreet Singh, Vijay Kandiah, Nikos Hardavellas,
// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
// The University of British Columbia, Northwestern University, Purdue University
// Copyright (c) 2009-2021, Tor M. Aamodt, Inderpreet Singh, Vijay Kandiah,
// Nikos Hardavellas, Mahmoud Khairy, Junrui Pan, Timothy G. Rogers The
// University of British Columbia, Northwestern University, Purdue University
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// 1. Redistributions of source code must retain the above copyright notice,
// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
// 3. Neither the names of The University of British Columbia, Northwestern
// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
Expand Down Expand Up @@ -64,24 +65,24 @@ enum _memory_space_t {
#ifndef COEFF_STRUCT
#define COEFF_STRUCT

struct PowerscalingCoefficients{
double int_coeff;
double int_mul_coeff;
double int_mul24_coeff;
double int_mul32_coeff;
double int_div_coeff;
double fp_coeff;
double dp_coeff;
double fp_mul_coeff;
double fp_div_coeff;
double dp_mul_coeff;
double dp_div_coeff;
double sqrt_coeff;
double log_coeff;
double sin_coeff;
double exp_coeff;
double tensor_coeff;
double tex_coeff;
struct PowerscalingCoefficients {
double int_coeff;
double int_mul_coeff;
double int_mul24_coeff;
double int_mul32_coeff;
double int_div_coeff;
double fp_coeff;
double dp_coeff;
double fp_mul_coeff;
double fp_div_coeff;
double dp_mul_coeff;
double dp_div_coeff;
double sqrt_coeff;
double log_coeff;
double sin_coeff;
double exp_coeff;
double tensor_coeff;
double tex_coeff;
};
#endif

Expand Down Expand Up @@ -974,18 +975,22 @@ class inst_t {
memory_op == memory_store);
}

bool is_fp() const { return ((sp_op == FP__OP));} //VIJAY
bool is_fpdiv() const { return ((sp_op == FP_DIV_OP));}
bool is_fpmul() const { return ((sp_op == FP_MUL_OP));}
bool is_dp() const { return ((sp_op == DP___OP));}
bool is_dpdiv() const { return ((sp_op == DP_DIV_OP));}
bool is_dpmul() const { return ((sp_op == DP_MUL_OP));}
bool is_imul() const { return ((sp_op == INT_MUL_OP));}
bool is_imul24() const { return ((sp_op == INT_MUL24_OP));}
bool is_imul32() const { return ((sp_op == INT_MUL32_OP));}
bool is_idiv() const { return ((sp_op == INT_DIV_OP));}
bool is_sfu() const {return ((sp_op == FP_SQRT_OP) || (sp_op == FP_LG_OP) || (sp_op == FP_SIN_OP) || (sp_op == FP_EXP_OP) || (sp_op == TENSOR__OP));}
bool is_alu() const {return (sp_op == INT__OP);}
bool is_fp() const { return ((sp_op == FP__OP)); } // VIJAY
bool is_fpdiv() const { return ((sp_op == FP_DIV_OP)); }
bool is_fpmul() const { return ((sp_op == FP_MUL_OP)); }
bool is_dp() const { return ((sp_op == DP___OP)); }
bool is_dpdiv() const { return ((sp_op == DP_DIV_OP)); }
bool is_dpmul() const { return ((sp_op == DP_MUL_OP)); }
bool is_imul() const { return ((sp_op == INT_MUL_OP)); }
bool is_imul24() const { return ((sp_op == INT_MUL24_OP)); }
bool is_imul32() const { return ((sp_op == INT_MUL32_OP)); }
bool is_idiv() const { return ((sp_op == INT_DIV_OP)); }
bool is_sfu() const {
return ((sp_op == FP_SQRT_OP) || (sp_op == FP_LG_OP) ||
(sp_op == FP_SIN_OP) || (sp_op == FP_EXP_OP) ||
(sp_op == TENSOR__OP));
}
bool is_alu() const { return (sp_op == INT__OP); }

unsigned get_num_operands() const { return num_operands; }
unsigned get_num_regs() const { return num_regs; }
Expand All @@ -1010,7 +1015,7 @@ class inst_t {
operation_pipeline op_pipe; // code (uarch visible) identify the pipeline of
// the operation (SP, SFU or MEM)
mem_operation mem_op; // code (uarch visible) identify memory type
bool const_cache_operand; // has a load from constant memory as an operand
bool const_cache_operand; // has a load from constant memory as an operand
_memory_op_t memory_op; // memory_op used by ptxplus
unsigned num_operands;
unsigned num_regs; // count vector operand as one register operand
Expand Down Expand Up @@ -1057,7 +1062,7 @@ class warp_inst_t : public inst_t {
m_empty = true;
m_config = NULL;

// Ni:
// Ni:
m_is_ldgsts = false;
m_is_ldgdepbar = false;
m_is_depbar = false;
Expand All @@ -1077,7 +1082,7 @@ class warp_inst_t : public inst_t {
m_is_cdp = 0;
should_do_atomic = true;

// Ni:
// Ni:
m_is_ldgsts = false;
m_is_ldgdepbar = false;
m_is_depbar = false;
Expand Down
Loading

0 comments on commit e1afc53

Please sign in to comment.