Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c5c7cec
remedy segfault with openmpi/intelmpi in MPI_Reduc
airmler Nov 13, 2020
594ecc8
1.) contraction time estimate returns value in sec
airmler Feb 19, 2021
bf6ecd3
comment out one print statement
airmler Feb 24, 2021
e40c5f3
undo changes related to time estimates
airmler May 12, 2021
e06635f
add dryRun feature. without any output
airmler May 12, 2021
19f8385
change output for dryRun
airmler May 17, 2021
fc734f1
change of model + very lengthy output in dryRun
airmler May 28, 2021
f260af2
minor changes on dryRun output
airmler Jun 4, 2021
67b7e0b
solomonik fix: disable fast slice when tensors are not mapped to all …
airmler Jul 19, 2021
4876676
simple test
airmler Dec 21, 2021
32dfea2
blocked communicator for summa2d and matrices only
airmler Dec 28, 2021
e4f1a90
profile bcast! temp. as it needs an extra barrier
airmler Dec 28, 2021
88c1013
fix typo in last commit
airmler Dec 28, 2021
53ae5da
aG:Add --without-scalapack to the configure script
airmler Mar 28, 2022
56939f1
Merge branch 'master' of https://github.com/airmler/ctf
airmler Apr 29, 2022
1df94ea
add node-awareness. still segfaulting in dryRun
airmler May 2, 2022
5094ae9
fix segfaults in dryRun
airmler May 2, 2022
63bbf18
add node awareness to dryRun branch
airmler May 9, 2022
dad2137
Merge branch 'master' of https://github.com/airmler/ctf
airmler Nov 11, 2022
64246ca
Add cc4s-model-trainer and change dump of TUNE data:
airmler Aug 5, 2024
351d780
Merge branch 'master' of github.com:airmler/ctf
airmler Aug 5, 2024
dcdcf23
minor changes in cc4s_model_trainer
airmler Aug 8, 2024
6906d62
Merge branch 'master' of https://github.com/airmler/ctf
airmler Aug 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ uninstall:
EXAMPLES = algebraic_multigrid apsp bitonic_sort btwn_central ccsd checkpoint dft_3D fft force_integration force_integration_sparse jacobi matmul neural_network particle_interaction qinformatics recursive_matmul scan sparse_mp3 sparse_permuted_slice spectral_element spmv sssp strassen trace mis mis2 ao_mo_transf block_sparse checkpoint_sparse hosvd mttkrp fft_with_idx_partition
TESTS = bivar_function bivar_transform ccsdt_map_test ccsdt_t3_to_t2 dft diag_ctr diag_sym endomorphism_cust endomorphism_cust_sp endomorphism gemm_4D multi_tsr_sym permute_multiworld readall_test readwrite_test repack scalar speye sptensor_sum subworld_gemm sy_times_ns test_suite univar_function weigh_4D reduce_bcast

BENCHMARKS = bench_contraction bench_nosym_transp bench_redistribution model_trainer
BENCHMARKS = model_trainer_cc4s model_trainer bench_contraction bench_nosym_transp

SCALAPACK_TESTS = qr svd eigh

Expand Down
170 changes: 170 additions & 0 deletions bench/model_trainer_cc4s.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/** Copyright (c) 2011, Edgar Solomonik, all rights reserved.
* \addtogroup benchmarks
* @{
* \addtogroup model_trainer
* @{
* \brief Executes a set of different contractions on different processor counts to train model parameters
*/

#include <sys/types.h>
#include <sys/stat.h>
#include <ctf.hpp>
#define TEST_SUITE
#include "../examples/ccsd.cxx"
#include "../examples/sparse_mp3.cxx"
#undef TEST_SUITE
using namespace CTF;

namespace CTF_int{
void update_all_models(MPI_Comm comm);
}

struct Ccsd_dimensions {
int64_t No;
int64_t Nv;
int64_t Nx;
int64_t Ng;
};

Ccsd_dimensions get_ccsd_dimensions(double mem_per_core, int64_t nvfac, World &dw) {
int np;
MPI_Comm_size(dw.comm, &np);
int64_t No(10);
while ( No*No*No*No*nvfac*nvfac*8./np/1024/1024 < mem_per_core) No++;
return Ccsd_dimensions({No, No*nvfac, No, (int64_t) No*nvfac*2.5});
}

void ph1_contraction(int64_t No, int64_t Nv, World &dw) {
int64_t vvoo[] = {Nv, Nv, No, No};
int syms[] = {NS, NS, NS, NS};
CTF::Tensor< double > T(4, vvoo, syms, dw, "T");
CTF::Tensor< double > V(4, vvoo, syms, dw, "V");
CTF::Tensor< double > R(4, vvoo, syms, dw, "R");
V.fill_random(0, 1);
T.fill_random(0, 1);
R["abij"] = T["acik"] * V["cbkj"];
}

void ph2_contraction(int64_t No, int64_t Nv, World &dw) {
int64_t vvoo[] = {Nv, Nv, No, No};
int64_t ovvo[] = {No, Nv, Nv, No};
int syms[] = {NS, NS, NS, NS};
CTF::Tensor< double > T(4, vvoo, syms, dw, "T");
CTF::Tensor< double > V(4, ovvo, syms, dw, "V");
CTF::Tensor< double > R(4, vvoo, syms, dw, "R");
V.fill_random(0, 1);
T.fill_random(0, 1);
R["abij"] = T["acik"] * V["kbcj"];
}

void ggv_contraction(int64_t Nv, int64_t Nx, int64_t Ng, World &dw) {
int64_t gxv[] = {Ng, Nx, Nv};
int64_t vvxx[] = {Nv, Nv, Nx, Nx};
int syms[] = {NS, NS, NS, NS};
CTF::Tensor< double > G(3, gxv, syms, dw, "B");
CTF::Tensor< double > V(4, vvxx, syms, dw, "C");
G.fill_random(0, 1);
V["cdxy"] = G["Gxc"] * G["Gyd"];
}

void rvt_contraction(int64_t No, int64_t Nv, int64_t Nx, World &dw) {
int64_t vvoo[] = {Nv, Nv, No, No};
int64_t xxoo[] = {Nx, Nx, No, No};
int64_t vvxx[] = {Nv, Nv, Nx, Nx};
int syms[] = {NS, NS, NS, NS};
CTF::Tensor< double > T(4, vvoo, syms, dw, "T");
CTF::Tensor< double > V(4, vvxx, syms, dw, "V");
CTF::Tensor< double > R(4, xxoo, syms, dw, "R");
V.fill_random(0, 1);
T.fill_random(0, 1);
R["abij"] = V["xyab"] * T["xyij"];
}

void train_ccsd(World & dw, double mem_per_core, int64_t nvfac, int c_id){
auto dim = get_ccsd_dimensions(mem_per_core, nvfac, dw);
if (c_id & 1) ph1_contraction(dim.No, dim.Nv, dw);
if (c_id & 2) ph2_contraction(dim.No, dim.Nv, dw);
if (c_id & 4) ggv_contraction(dim.Nv, dim.Nx, dim.Ng, dw);
if (c_id & 8) rvt_contraction(dim.No, dim.Nv, dim.Nx, dw);
}



void train_all(std::string dump_path, int num_iterations, int rounds, int ppn){
World dw("hallo", 0, ppn);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);


for (int i=0; i<num_iterations; i++){
if (rank == 0){
printf("Starting iteration %d/%d\n", i+1,num_iterations);
}
for (int j(0); j < rounds; j++) {
train_ccsd(dw, 10., 8, 15);
train_ccsd(dw, 10., 12, 15);
train_ccsd(dw, 25., 8, 15);
train_ccsd(dw, 25., 12, 15);
train_ccsd(dw, 25., 16, 15);
CTF_int::update_all_models(dw.comm);
if (rank == 0) printf("Completed training round %d/%d\n", j+1, rounds);
}
}


// CTF_int::write_all_models(coeff_file);
if (rank == 0) CTF_int::print_all_models();

if (dump_path.size()) CTF_int::dump_touched_models(dump_path);

}

char* getCmdOption(char ** begin,
char ** end,
const std::string & option){
char ** itr = std::find(begin, end, option);
if (itr != end && ++itr != end){
return *itr;
}
return 0;
}


int main(int argc, char ** argv){
int rank, np;
int const in_num = argc;
char ** input_str = argv;

MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &np);

std::string dump_path("./data");
int iterations(3), rounds(3), ppn(0);
if (getCmdOption(input_str, input_str+in_num, "-write")){
dump_path = getCmdOption(input_str, input_str+in_num, "-write");
}
if (getCmdOption(input_str, input_str+in_num, "-ppn")){
ppn = atoi(getCmdOption(input_str, input_str+in_num, "-ppn"));
}

struct stat info;
if (!rank) {
if(!stat( dump_path.c_str(), &info ) != 0 ) {
printf( "Warning: dumping data into existing directory %s.\n", dump_path.c_str() );
} else {
mkdir(dump_path.c_str(), 0777);
}
printf("we train\n");
}
train_all(dump_path, iterations, rounds, ppn);


MPI_Finalize();
return 0;
}

/**
* @}
* @}
*/
9 changes: 7 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function usage
echo -e '\t--with-lapack Tells CTF build to enable LAPACK functionality regardless of whether LAPACK libs have been given.'
echo
echo -e '\t--with-scalapack Tells CTF build to enable ScaLAPACK functionality regardless of whether ScaLAPACK libs have been given.'
echo -e '\t--without-scalapack Tells CTF build to disable ScaLAPACK functionality regardless of whether ScaLAPACK libs have been given.'
echo
echo -e '\t--build-scalapack Tells CTF to download and build ScaLAPACK library.'
echo
Expand Down Expand Up @@ -498,6 +499,7 @@ depstype=normal
WITH_CUDA=0
WITH_LAPACK=0
WITH_SCALAPACK=0
WITHOUT_SCALAPACK=0
WITH_STATIC=1
WITH_DYNAMIC=1
BUILD_SCALAPACK=0
Expand All @@ -518,6 +520,9 @@ while [ "x$1" != "x" ]; do
--with-scalapack)
WITH_SCALAPACK=1
;;
--without-scalapack)
WITHOUT_SCALAPACK=1
;;
--build-scalapack)
BUILD_SCALAPACK=1
;;
Expand Down Expand Up @@ -1035,7 +1040,7 @@ if [ $BUILD_SCALAPACK = 1 ]; then
fi

USING_SCALA=0
if [ $WITH_STATIC = 1 ]; then
if [[ $WITH_STATIC = 1 && $WITHOUT_SCALAPACK = 0 ]]; then
echo -n 'Checking for static ScaLAPACK... '
if testlink "$LIB_PATH $LIBS" $PDGEMM $VERBOSE; then
echo 'static SCALAPACK found.'
Expand Down Expand Up @@ -1069,7 +1074,7 @@ if [ $WITH_STATIC = 1 ]; then
fi
fi

if [ $WITH_DYNAMIC = 1 ]; then
if [[ $WITH_DYNAMIC = 1 && $WITHOUT_SCALAPACK = 0 ]]; then
echo -n 'Checking for dynamic ScaLAPACK... '
if testldlink "$LD_LIB_PATH" "$LD_LIBS" $PDGEMM $VERBOSE; then
echo 'dynamic SCALAPACK found.'
Expand Down
Loading