Skip to content

Commit

Permalink
Merge pull request #39 from CannyLab/refactor_fit_tsne
Browse files Browse the repository at this point in the history
Refactor fit tsne
  • Loading branch information
DavidMChan authored Jun 11, 2019
2 parents 46775fe + 81b925f commit 05c1f19
Show file tree
Hide file tree
Showing 43 changed files with 412 additions and 2,609 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tsne_utils
compile_commands.json

*.o
*.so
Expand All @@ -24,11 +25,15 @@ Multicore-TSNE/dist/*
build/*

# exception to the rule
!build/.gitkeep
!build/.gitkeep

# Ignore animation
visualization/animation.gif

.DS_Store
.mypy_cache/
.vscode/

# vim
*.swp
*.swo
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set (CMAKE_PROJECT_VERSION_MAJOR 1)
set (CMAKE_PROJECT_VERSION_MINOR 0)
set (CMAKE_PROJECT_VERSION_PATH 0)
set (CMAKE_SKIP_RULE_DEPENDENCY TRUE)
set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)

# Options
Expand Down Expand Up @@ -57,13 +58,13 @@ SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};
-O3
-Xptxas -dlcm=cg
-gencode=arch=compute_30,code=sm_30
-gencode=arch=compute_35,code=sm_35
-gencode=arch=compute_50,code=sm_50
-gencode=arch=compute_52,code=sm_52
-gencode=arch=compute_60,code=sm_60
-gencode=arch=compute_61,code=sm_61
-gencode=arch=compute_70,code=sm_70
-gencode=arch=compute_30,code=sm_30
-gencode=arch=compute_35,code=sm_35
-gencode=arch=compute_50,code=sm_50
-gencode=arch=compute_52,code=sm_52
-gencode=arch=compute_60,code=sm_60
-gencode=arch=compute_61,code=sm_61
-gencode=arch=compute_70,code=sm_70
-std=c++11
-Xcompiler '-O3'
-Xcompiler '-fPIC'
Expand Down Expand Up @@ -149,15 +150,14 @@ set(SOURCES

# Kernels
src/kernels/apply_forces.cu
src/kernels/bh_attr_forces.cu
src/kernels/attr_forces.cu
src/kernels/rep_forces.cu
src/kernels/perplexity_search.cu
src/kernels/initialization.cu
src/kernels/nbodyfft.cu

# Method files
src/ext/pymodule_ext.cu
src/bh_tsne.cu
src/nbodyfft.cu
# src/naive_tsne.cu
src/fit_tsne.cu
)


Expand Down
7 changes: 3 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
# export PATH=/usr/local/cuda-9.0/bin:$PATH
# export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
git submodule init
git submodule update
git submodule update
cd ./build
cmake .. -DBUILD_PYTHON=TRUE -DWITH_MKL=FALSE -DCMAKE_C_COMPILER=gcc-4.9 -DCMAKE_CXX_COMPILER=g++-4.9
pwd
make -j10
make
cd python/
pwd
Expand Down
4 changes: 2 additions & 2 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "tsnecuda" %}
{% set version = "0.1.1" %}
{% set version = "0.2.1" %}

package:
name: '{{ name|lower }}'
Expand All @@ -8,7 +8,7 @@ package:
source:
git_url: https://github.com/CannyLab/tsne-cuda.git
git_rev: HEAD

requirements:
build:
- python
Expand Down
15 changes: 0 additions & 15 deletions src/Makefile

This file was deleted.

29 changes: 11 additions & 18 deletions src/exe/main.cu
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@

// This file exposes a main file which does most of the testing with command line
// This file exposes a main file which does most of the testing with command line
// args, so we don't have to re-build to change options.

// Detailed includes
#include "common.h"
#include "util/data_utils.h"
#include "util/cuda_utils.h"
#include "util/random_utils.h"
#include "util/distance_utils.h"
#include "naive_tsne.h"
#include "naive_tsne_cpu.h"
#include "bh_tsne.h"
#include "include/util/data_utils.h"
#include "include/fit_tsne.h"
#include <time.h>
#include <string>

Expand Down Expand Up @@ -45,7 +38,7 @@ int main(int argc, char** argv) {
("q,dim", "Point Dimensions", cxxopts::value<int>()->default_value("50"))
("j,device", "Device to run on", cxxopts::value<int>()->default_value("0"))
("h,help", "Print help");

// Parse command line options
auto result = options.parse(argc, argv);

Expand Down Expand Up @@ -98,7 +91,7 @@ int main(int argc, char** argv) {
}

// Do the t-SNE
tsnecuda::bh::RunTsne(opt, gpu_opt);
tsnecuda::RunTsne(opt, gpu_opt);

// Clean up the data
delete[] data;
Expand Down Expand Up @@ -134,7 +127,7 @@ int main(int argc, char** argv) {
}

// Do the t-SNE
tsnecuda::bh::RunTsne(opt, gpu_opt);
tsnecuda::RunTsne(opt, gpu_opt);

// Clean up the data
delete[] data;
Expand All @@ -151,7 +144,7 @@ int main(int argc, char** argv) {

// DO the T-SNE
printf("Starting TSNE calculation with %u points.\n", num_images);

// Construct the options
tsnecuda::Options opt(nullptr, data, num_images, num_columns*num_rows*num_channels);
opt.perplexity = FOPT(perplexity);
Expand All @@ -171,8 +164,8 @@ int main(int argc, char** argv) {
}

// Do the t-SNE
tsnecuda::bh::RunTsne(opt, gpu_opt);
tsnecuda::RunTsne(opt, gpu_opt);

// Clean up the data
delete[] data;

Expand All @@ -194,7 +187,7 @@ int main(int argc, char** argv) {

// Do the T-SNE
printf("Starting TSNE calculation with %u points.\n", IOPT(num-points));

// Construct the options
tsnecuda::Options opt(nullptr, thrust::raw_pointer_cast(h_X.data()), IOPT(num-points), IOPT(dim));
opt.perplexity = FOPT(perplexity);
Expand All @@ -214,7 +207,7 @@ int main(int argc, char** argv) {
}

// Do the t-SNE
tsnecuda::bh::RunTsne(opt, gpu_opt);
tsnecuda::RunTsne(opt, gpu_opt);

} else {
std::cout << "Dataset not recognized..." << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions src/ext/pymodule_ext.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// Implementation file for the python extensions

#include "include/ext/pymodule_ext.h"
#include "ext/pymodule_ext.h"

void pymodule_bh_tsne(float *result,
float* points,
Expand Down Expand Up @@ -108,7 +108,7 @@ void pymodule_bh_tsne(float *result,
}

// Do the t-SNE
tsnecuda::bh::RunTsne(opt, gpu_opt);
tsnecuda::RunTsne(opt, gpu_opt);

// Copy the data back from the GPU
cudaDeviceSynchronize();
Expand Down
Loading

0 comments on commit 05c1f19

Please sign in to comment.