Skip to content

Commit

Permalink
Update script
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcrimsontianyu committed Dec 7, 2024
1 parent 3e30acf commit a0035b5
Showing 1 changed file with 83 additions and 14 deletions.
97 changes: 83 additions & 14 deletions run_benchmark/run_gds.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

import os
import subprocess
import copy


class test_manager:
def __init__(self):
self.test_env = os.environ.copy()
self.test_env = copy.deepcopy(os.environ)

# Hot cache (not set) or cold cache (set)
self.test_env["CUDF_BENCHMARK_DROP_CACHE"] = "true"

self.test_env["TMPDIR"] = "/home/coder/cudf/run_benchmark"
# self.test_env["TMPDIR"] = "/home/coder/cudf/run_benchmark"
self.test_env["TMPDIR"] = "/mnt/profile/run_benchmark"
self.test_env["CUFILE_LOGGING_LEVEL"] = "WARN"

self.test_env["CUDA_VISIBLE_DEVICES"] = "1"

self.color_green = '\x1b[1;32m'
self.color_end = '\x1b[0m'

Expand All @@ -30,12 +34,13 @@ def run_bench_command(self, subtest_env):
# full_command = "{} -d 0 -b {} -a io=FILEPATH --min-samples 40".format(
# my_bin, my_option)

print(f"Full command: {full_command}")
subprocess.run([full_command], shell=True,
env=subtest_env)

def use_policy_gds(self):
# Let cuDF use cuFile API that uses GDS
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "GDS"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "false"
current_setup = "{}_cufile_compat_{}".format(subtest_env["LIBCUDF_CUFILE_POLICY"],
Expand All @@ -51,7 +56,7 @@ def use_policy_gds(self):
self.run_bench_command(subtest_env)

# Let cuDF use cuFile API that uses POSIX IO
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "GDS"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "true"
subtest_env["CUFILE_FORCE_COMPAT_MODE"] = "true"
Expand All @@ -69,7 +74,7 @@ def use_policy_gds(self):

def use_policy_always(self):
# Let cuDF use cuFile API that uses GDS
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "ALWAYS"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "false"
current_setup = "{}_cufile_compat_{}".format(subtest_env["LIBCUDF_CUFILE_POLICY"],
Expand All @@ -85,7 +90,7 @@ def use_policy_always(self):
self.run_bench_command(subtest_env)

# Let cuDF use cuFile API that uses POSIX IO
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "ALWAYS"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "true"
subtest_env["CUFILE_FORCE_COMPAT_MODE"] = "true"
Expand All @@ -105,7 +110,7 @@ def use_policy_kvikio(self):
num_threads_options = [1, 2, 4, 8]

# Let KVIKIO use cuFile API that uses GDS
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "off"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "false"
Expand All @@ -126,7 +131,7 @@ def use_policy_kvikio(self):
self.run_bench_command(subtest_env)

# Let KVIKIO use cuFile API that uses POSIX IO
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "off"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "true"
Expand All @@ -148,7 +153,7 @@ def use_policy_kvikio(self):
self.run_bench_command(subtest_env)

# Let KVIKIO use POSIX IO
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "on"
for num_threads in num_threads_options:
Expand All @@ -168,7 +173,7 @@ def use_policy_kvikio(self):

def use_policy_off(self):
# Let cuDF use POSIX IO
subtest_env = self.test_env.copy()
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "OFF"
current_setup = "{}".format(
subtest_env["LIBCUDF_CUFILE_POLICY"])
Expand All @@ -182,10 +187,74 @@ def use_policy_off(self):
current_setup, self.color_end))
self.run_bench_command(subtest_env)

def compare_kvik_io_gds_with_posix(self):
num_threads = 4

# Let KVIKIO use cuFile API that uses GDS
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "off"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "false"
subtest_env["KVIKIO_NTHREADS"] = str(num_threads)
current_setup = "{}_kvik_compat_{}_cufile_compat_{}_{}".format(subtest_env["LIBCUDF_CUFILE_POLICY"],
subtest_env["KVIKIO_COMPAT_MODE"],
subtest_env["CUFILE_ALLOW_COMPAT_MODE"],
subtest_env["KVIKIO_NTHREADS"])
if "CUDF_BENCHMARK_DROP_CACHE" in subtest_env:
current_setup += "_cold"
else:
current_setup += "_hot"
subtest_env["CUFILE_LOGFILE_PATH"] = "cufile_log_{}.txt".format(
current_setup)
print("{}--> {}{}".format(self.color_green,
current_setup, self.color_end))
self.run_bench_command(subtest_env)

# Let KVIKIO use cuFile API that uses POSIX IO
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "off"
subtest_env["CUFILE_ALLOW_COMPAT_MODE"] = "true"
subtest_env["CUFILE_FORCE_COMPAT_MODE"] = "true"
subtest_env["KVIKIO_NTHREADS"] = str(num_threads)
current_setup = "{}_kvik_compat_{}_cufile_compat_{}_{}".format(subtest_env["LIBCUDF_CUFILE_POLICY"],
subtest_env["KVIKIO_COMPAT_MODE"],
subtest_env["CUFILE_ALLOW_COMPAT_MODE"],
subtest_env["KVIKIO_NTHREADS"])
if "CUDF_BENCHMARK_DROP_CACHE" in subtest_env:
current_setup += "_cold"
else:
current_setup += "_hot"
subtest_env["CUFILE_LOGFILE_PATH"] = "cufile_log_{}.txt".format(
current_setup)
print("{}--> {}{}".format(self.color_green,
current_setup, self.color_end))
self.run_bench_command(subtest_env)

# Let KVIKIO use POSIX IO
subtest_env = copy.deepcopy(self.test_env)
subtest_env["LIBCUDF_CUFILE_POLICY"] = "KVIKIO"
subtest_env["KVIKIO_COMPAT_MODE"] = "on"
subtest_env["KVIKIO_NTHREADS"] = str(num_threads)
current_setup = "{}_kvik_compat_{}_{}".format(subtest_env["LIBCUDF_CUFILE_POLICY"],
subtest_env["KVIKIO_COMPAT_MODE"],
subtest_env["KVIKIO_NTHREADS"])
if "CUDF_BENCHMARK_DROP_CACHE" in subtest_env:
current_setup += "_cold"
else:
current_setup += "_hot"
subtest_env["CUFILE_LOGFILE_PATH"] = "cufile_log_{}.txt".format(
current_setup)
print("{}--> {}{}".format(self.color_green,
current_setup, self.color_end))
self.run_bench_command(subtest_env)


if __name__ == '__main__':
tm = test_manager()
tm.use_policy_gds()
tm.use_policy_always()
tm.use_policy_kvikio()
tm.use_policy_off()
# tm.use_policy_gds()
# tm.use_policy_always()
# tm.use_policy_kvikio()
# tm.use_policy_off()

tm.compare_kvik_io_gds_with_posix()

0 comments on commit a0035b5

Please sign in to comment.