From 6c911917a461fc4233d649306122f54eb74f13ed Mon Sep 17 00:00:00 2001 From: He Sichao <1310722434@qq.com> Date: Tue, 10 Sep 2024 21:21:53 +0800 Subject: [PATCH] Update --- benchmarks/README.md | 19 +++++++++++++++++++ benchmarks/requirements.txt | 3 ++- benchmarks/requirements_cuda.txt | 8 +++++--- benchmarks/src/basic/csrmv_taichi_VS_csrmv.py | 4 +++- benchmarks/src/model/linear.py | 14 ++++++++------ benchmarks/src/model/test_COBA.py | 2 +- benchmarks/src/model/test_MultipleArea.py | 2 +- 7 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 benchmarks/README.md diff --git a/benchmarks/README.md b/benchmarks/README.md new file mode 100644 index 0000000..32544e7 --- /dev/null +++ b/benchmarks/README.md @@ -0,0 +1,19 @@ +# Benchmark Tests + +This directory contains a series of benchmark tests designed to evaluate performance. The test files are located in the `src/basic` and `src/model` folders, specifically: + +- `basic` folder: Contains tests for basic matrix operations, event-driven CSR matrix operations and jitconn matrix operations. +- `model` folder: Contains tests for complex models, such as `test_COBA.py` and `test_MultipleArea.py`. + + +To run these tests, ensure all necessary dependencies are installed. You can install the dependencies using the following command: + +```bash +pip install -r requirements.txt +``` + +or if you are using a CUDA-enabled GPU, you can install the dependencies using the following command: + +```bash +pip install -r requirements_cuda.txt +``` diff --git a/benchmarks/requirements.txt b/benchmarks/requirements.txt index 382131d..07ab7d5 100644 --- a/benchmarks/requirements.txt +++ b/benchmarks/requirements.txt @@ -4,4 +4,5 @@ taichi==1.7.0 brainpylib==0.2.6 pandas matplotlib -seaborn \ No newline at end of file +seaborn +numpy==1.26.4 \ No newline at end of file diff --git a/benchmarks/requirements_cuda.txt b/benchmarks/requirements_cuda.txt index 0eb324a..a4380fe 100644 --- a/benchmarks/requirements_cuda.txt +++ b/benchmarks/requirements_cuda.txt @@ -1,7 +1,9 @@ -jax[cuda12_pip]==0.4.14 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html +-f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html +jax[cuda12_pip]==0.4.14 brainpy==2.4.6.post5 taichi==1.7.0 -brainpylib==0.2.6 +brainpylib-cu12x==0.2.6 pandas matplotlib -seaborn \ No newline at end of file +seaborn +numpy==1.26.4 \ No newline at end of file diff --git a/benchmarks/src/basic/csrmv_taichi_VS_csrmv.py b/benchmarks/src/basic/csrmv_taichi_VS_csrmv.py index 1db2462..c502ecb 100644 --- a/benchmarks/src/basic/csrmv_taichi_VS_csrmv.py +++ b/benchmarks/src/basic/csrmv_taichi_VS_csrmv.py @@ -12,7 +12,9 @@ import pandas as pd import taichi as ti -bm.set_platform('cpu') + +bm.set_platform('gpu') + s = [1000, 5000, 10000, 15000, 20000, 25000, 30000] p = [0.1, 0.2, 0.3, 0.4, 0.5] diff --git a/benchmarks/src/model/linear.py b/benchmarks/src/model/linear.py index bf8e1ce..37d7421 100644 --- a/benchmarks/src/model/linear.py +++ b/benchmarks/src/model/linear.py @@ -630,10 +630,11 @@ def __init__( def update(self, x): if x.ndim == 1: if self.method is None: - event_csrmv = bm.event.csrmv_taichi + return bm.event.csrmv_taichi(self.weight, self.indices, self.indptr, x, + shape=(self.conn.pre_num, self.conn.post_num), + transpose=self.transpose,)[0] else: - event_csrmv = bm.event.csrmv - return event_csrmv(self.weight, self.indices, self.indptr, x, + return bm.event.csrmv(self.weight, self.indices, self.indptr, x, shape=(self.conn.pre_num, self.conn.post_num), transpose=self.transpose,) elif x.ndim > 1: @@ -646,10 +647,11 @@ def update(self, x): def _batch_csrmv(self, x): if self.method is None: - event_csrmv = bm.event.csrmv_taichi + return bm.event.csrmv_taichi(self.weight, self.indices, self.indptr, x, + shape=(self.conn.pre_num, self.conn.post_num), + transpose=self.transpose,)[0] else: - event_csrmv = bm.event.csrmv - return event_csrmv(self.weight, self.indices, self.indptr, x, + return bm.event.csrmv(self.weight, self.indices, self.indptr, x, shape=(self.conn.pre_num, self.conn.post_num), transpose=self.transpose,) diff --git a/benchmarks/src/model/test_COBA.py b/benchmarks/src/model/test_COBA.py index 6be8002..1a313a0 100644 --- a/benchmarks/src/model/test_COBA.py +++ b/benchmarks/src/model/test_COBA.py @@ -17,7 +17,7 @@ EventJitFPNormalLinear_taichi = partial(EventJitFPNormalLinear, method=None) -bm.set_platform('cpu') +bm.set_platform('gpu') bm.disable_gpu_memory_preallocation() post_nums = [400, 4000, 40000, 400000, 4000000] diff --git a/benchmarks/src/model/test_MultipleArea.py b/benchmarks/src/model/test_MultipleArea.py index b0a2c95..51afd1f 100644 --- a/benchmarks/src/model/test_MultipleArea.py +++ b/benchmarks/src/model/test_MultipleArea.py @@ -15,7 +15,7 @@ from multiple_area_customized_op import (multiple_area_customized_op_E as syn_fun_E, multiple_area_customized_op_I as syn_fun_I) -bm.set_platform('cpu') +bm.set_platform('gpu') bm.disable_gpu_memory_preallocation() PATH = os.path.dirname(os.path.abspath(__file__))