Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ data/
utils/__pycache__/

log/

__pycache__
116 changes: 116 additions & 0 deletions benchmark/data_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import struct
import random
import threading
import time
import os
from queue import Queue

class RandomMessage(object):
def __init__(self):
self.filename = None
# message size (default 1 MBytes)
self.size = 1024 * 1024
# the number of integer elements in a message
self.count = int(self.size / 4)

self.data = None
self.binary = None

self.generate()

# thread to process pseudo message
self.q = Queue()
self.terminate_event = threading.Event()
self.thread = threading.Thread(target=self._run)
self.thread.start()

# statistics
self.total_message = 0
self.min_start_time = None
self.max_end_time = None
self.acc_process_time = 0
self.status = True

def generate(self, size = None, filename = None):
if size is None: size = self.size
self.filename = filename

self.size = size - size%4
self.count = int(self.size/4)

if filename is None or not os.path.exists(filename):
self.data = [random.randint(1, 99999) for _ in range(self.count)]
self.binary = struct.pack('{:d}i'.format(self.count), *self.data)
self.save()
else:
self.load()

def save(self):
if self.filename is None: return
if self.binary is None: return
with open(self.filename, 'wb') as f:
f.write(self.binary)

def load(self):
if self.filename is None: return
with open(self.filename, 'rb') as f:
self.binary = f.read()
self.data = list(struct.unpack('{:d}i'.format(self.count), self.binary))

def is_equal(self, binary):
return self.binary == binary

def add_message(self, binary):
"""This function will be accessed by multiple threads"""
self.q.put([time.time(), binary])

def _run(self):
while not self.terminate_event.isSet():
start_time, binary = self.q.get()

if binary is None:
break

# simple operation (e.g. validate data or some other operations)
self.status = self.status and self.is_equal(binary)
end_time = time.time()

# update statistics
self.total_message = self.total_message + 1

self.min_start_time = min(self.min_start_time, start_time) \
if self.min_start_time is not None else start_time

self.max_end_time = max(self.max_end_time, end_time) \
if self.max_end_time is not None else end_time

elapsed = end_time - start_time
self.acc_process_time = self.acc_process_time + elapsed

self.q.task_done()

def join(self):
if not self.thread.is_alive():
return

self.q.join() # block until all tasks are done in the queue
self.terminate_event.set()
self.thread.join()

def show_statistics(self):
print("=================================================")
print("Status : {}".format("PASSED" if self.status else "FAILED"))
print("Total message received: {}".format(self.total_message))
if self.total_message:
print("Min. start time : {:.3f} sec".format(self.min_start_time))
print("Max. end time : {:.3f} sec".format(self.max_end_time))
print("Acc. process time : {:.3f} sec".format(self.acc_process_time))
print("Total elapsed time : {:.3f} sec".format(self.max_end_time - self.min_start_time))
print("Avg. process time : {:.3f} sec".format(self.acc_process_time/self.total_message))
print("Throughput : {:.3f} MBytes/sec".format(
self.total_message*self.size/1024/1024/(self.max_end_time - self.min_start_time)
))
print("Throughput : {:.3f} Messages/sec".format(
self.total_message/(self.max_end_time - self.min_start_time)
))
print("=================================================")
68 changes: 68 additions & 0 deletions benchmark/results/run_benchmark_summit_200.lsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
# Begin LSF Directives
#BSUB -P CSC299
#BSUB -W 1:00
#BSUB -nnodes 6
#BSUB -J ws-test-200
#BSUB -o ws-test-200.o.%J
#BSUB -e ws-test-200.e.%J

module load gcc/8.1.1
module load curl/7.63.0
module load python/3.7.0-anaconda3-5.3.0

#set -x

root=`pwd`
mega=$(( 1024*1024 ))
msz_count=$(( 100 ))

for msz_mbytes in 1 2 4
do

echo
echo "========== 200 with ${msz_mbytes} MBytes =========="

# prepare data and launch web server
addr="http://`jsrun -n 1 hostname`:5000"
msz_size=$(( ${msz_mbytes} * ${mega} ))
msz_fn="${root}/msg_200.bin"
log_fn="${root}/msg_200.log"
echo "web server @ ${addr}"
jsrun -n 1 -a 1 -c 42 -g 0 -r 1 python3 ws_flask.py $addr $msz_size $msz_fn $log_fn &
ws_pid=$!
while [ ! -f ${msz_fn} ]
do
echo "wait pseudo-message"
sleep 1
done
echo "pseudo-message is ready!"

# start sending pseudo-messages
s_time="$(date -u +%s.%N)"
jsrun -n 5 -a 40 -c 40 -g 0 -r 1 python3 send_message.py "${addr}/messages" $msz_fn $msz_count
e_time="$(date -u +%s.%N)"

# print out statistics
total_ranks=$(( 5 * 40 ))
elapsed="$(bc -l <<<"$e_time-$s_time")"
out1=$(bc -l <<<"${msz_mbytes}*${msz_count}*${total_ranks}/(${e_time}-${s_time})")
out2=$(bc -l <<<"${msz_count}*${total_ranks}/(${e_time}-${s_time})")
echo
echo "# Ranks : $total_ranks"
echo "Message size : $msz_mbytes MBytes"
echo "# Message (per rank): $msz_count"
echo "Elapsed time : $elapsed sec"
echo "Throughput : $out1 MBytes/sec"
echo "Throughput : $out2 Messages/sec"
echo

# clean for the next run
jsrun -n 1 -c 1 curl --silent --output /dev/null -X POST "${addr}/shutdown"
rm -f ${msz_fn} ${log_fn}
wait $ws_pid
echo "======================================================"
echo

done

7 changes: 7 additions & 0 deletions benchmark/results/ws-test-200.e.512751
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Lmod is automatically replacing "xl/16.1.1-3" with "gcc/8.1.1".


Due to MODULEPATH changes, the following have been reloaded:
1) spectrum-mpi/10.3.0.1-20190611

109 changes: 109 additions & 0 deletions benchmark/results/ws-test-200.o.512751
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

========== 200 with 1 MBytes ==========
web server @ http://h19n15:5000
wait pseudo-message
wait pseudo-message
pseudo-message is ready!

# Ranks : 200
Message size : 1 MBytes
# Message (per rank): 100
Elapsed time : 171.537479508 sec
Throughput : 116.59259572522318211046 MBytes/sec
Throughput : 116.59259572522318211046 Messages/sec

=================================================
Status : PASSED
Total message received: 20000
Min. start time : 1563380683.435 sec
Max. end time : 1563380853.165 sec
Acc. process time : 5.965 sec
Total elapsed time : 169.731 sec
Avg. process time : 0.000 sec
Throughput : 117.834 MBytes/sec
Throughput : 117.834 Messages/sec
=================================================
======================================================


========== 200 with 2 MBytes ==========
web server @ http://h19n15:5000
wait pseudo-message
wait pseudo-message
pseudo-message is ready!

# Ranks : 200
Message size : 2 MBytes
# Message (per rank): 100
Elapsed time : 340.276443815 sec
Throughput : 117.55148123549517294405 MBytes/sec
Throughput : 58.77574061774758647202 Messages/sec

=================================================
Status : PASSED
Total message received: 20000
Min. start time : 1563380858.040 sec
Max. end time : 1563381197.162 sec
Acc. process time : 7.876 sec
Total elapsed time : 339.121 sec
Avg. process time : 0.000 sec
Throughput : 117.952 MBytes/sec
Throughput : 58.976 Messages/sec
=================================================
======================================================


========== 200 with 4 MBytes ==========
web server @ http://h19n15:5000
wait pseudo-message
wait pseudo-message
wait pseudo-message
pseudo-message is ready!

# Ranks : 200
Message size : 4 MBytes
# Message (per rank): 100
Elapsed time : 679.628615884 sec
Throughput : 117.71134724211570908910 MBytes/sec
Throughput : 29.42783681052892727227 Messages/sec

=================================================
Status : PASSED
Total message received: 20000
Min. start time : 1563381203.659 sec
Max. end time : 1563381881.362 sec
Acc. process time : 11.812 sec
Total elapsed time : 677.703 sec
Avg. process time : 0.001 sec
Throughput : 118.046 MBytes/sec
Throughput : 29.511 Messages/sec
=================================================
======================================================


------------------------------------------------------------
Sender: LSF System <lsfadmin@batch4>
Subject: Job 512751: <ws-test-200> in cluster <summit> Done

Job <ws-test-200> was submitted from host <login2> by user <sungsoo> in cluster <summit> at Wed Jul 17 12:12:03 2019
Job was executed on host(s) <1*batch4>, in queue <batch>, as user <sungsoo> in cluster <summit> at Wed Jul 17 12:24:34 2019
<42*h19n15>
<42*h19n16>
<42*h19n17>
<42*h19n18>
<42*h20n01>
<42*h20n02>
</ccs/home/sungsoo> was used as the home directory.
</gpfs/alpine/world-shared/csc299/sungsoo/ChimbukoVisualization/benchmark> was used as the working directory.
Started at Wed Jul 17 12:24:34 2019
Terminated at Wed Jul 17 12:44:43 2019
Results reported at Wed Jul 17 12:44:43 2019

The output (if any) is above this job summary.



PS:

Read file <ws-test-200.e.512751> for stderr output of this job.

55 changes: 55 additions & 0 deletions benchmark/run_benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

# test condition
#root=`pwd`
#nranks=10
#msz_mbytes=$(( 50 ))
#export msz_count=$(( 100 ))
#export filename="${root}/message.bin"

#export addr="http://`hostname`:5000"
export addr="http://127.0.0.1:5000"
echo "web server @ ${addr}"

mega=$(( 1024*1024 ))
msz_size=$(( ${msz_mbytes} * ${mega} ))

# run a web server
python3 ws_flask.py $addr $msz_size $filename &
ws_pid=$!
while [ ! -f ${filename} ]
do
echo "wait pseudo-message"
sleep 10
done
echo "pseudo-message is ready!"
#ls -al

sleep 1
# start send pseudo-messages
start_time="$(date -u +%s.%N)"
#mpirun -n $nranks ./send_message.sh
mpirun -n $nranks python3 send_message.py "${addr}/messages" $filename $msz_count
end_time="$(date -u +%s.%N)"

elapsed="$(bc -l <<<"$end_time-$start_time")"
throughput=$(bc -l <<<"${msz_mbytes}*${msz_count}*${nranks}/(${end_time}-${start_time})")
throughput2=$(bc -l <<<"${msz_count}*${nranks}/(${end_time}-${start_time})")
echo "================================================="
echo "From sender perspective ...."
echo "# Ranks : $nranks"
echo "Message size : $msz_mbytes MBytes"
echo "# Message (per rank): $msz_count "
echo "Total elapsed time : $elapsed sec"
echo "Throughput : $throughput MBytes/sec"
echo "Throughput : $throughput2 Messages/sec"
echo "================================================="

# at this point all message was sent, shutdown web server
#curl -X POST http://127.0.0.1:5000/shutdown
curl -X POST "${addr}/shutdown"
echo

wait $ws_pid
#kill -9 $ws_pid
rm -f ${root}/log.txt ${filename}
Loading