Skip to content
Snippets Groups Projects
Commit 523458a0 authored by axc67-pxs02's avatar axc67-pxs02
Browse files

fixed the example

parent a3a6f11c
No related branches found
No related tags found
No related merge requests found
#!/bin/bash #!/bin/bash
gfortran test.F90 ../src/.libs/libquicksched.a -I../src/ -fopenmp #gfortran test.F90 ../src/.libs/libquicksched.a -I../src/ -fopenmp
ifort test_n2.F90 -g ../src/.libs/libquicksched.a -I../src/ -fopenmp -o test_n2
...@@ -153,6 +153,8 @@ cells(cell_num)%dx = cells(cell_num)%dx * 10.0_dp ...@@ -153,6 +153,8 @@ cells(cell_num)%dx = cells(cell_num)%dx * 10.0_dp
cells(cell_num)%dy = cells(cell_num)%dy * 10.0_dp cells(cell_num)%dy = cells(cell_num)%dy * 10.0_dp
cells(cell_num)%dz = cells(cell_num)%dz * 10.0_dp cells(cell_num)%dz = cells(cell_num)%dz * 10.0_dp
cells(cell_num)%num_parts = count
End Subroutine cell_init End Subroutine cell_init
Subroutine runner(typ, data) BIND(C) Subroutine runner(typ, data) BIND(C)
...@@ -194,29 +196,31 @@ Integer(Kind=C_INT) :: num_threads ...@@ -194,29 +196,31 @@ Integer(Kind=C_INT) :: num_threads
!$omp parallel !$omp parallel
!$omp single !$omp single
num_threads = omp_get_thread_num() num_threads = Int(omp_get_num_threads(), C_INT)
!$omp end single !$omp end single
!$omp end parallel !$omp end parallel
print *, num_threads
runner_func = C_FUNLOC(runner) runner_func = C_FUNLOC(runner)
Allocate(cells(1:1000)) Allocate(cells(1:100))
do i = 1, 1000 do i = 1, 100
call cell_init(i, 1000) call cell_init(i, 500)
end do end do
sched = f_qsched_create() sched = f_qsched_create()
call qsched_init(sched, num_threads, 0) call qsched_init(sched, num_threads, 0)
do i=1, 1000 do i=1, 100
cell_res(i) = qsched_addres(sched, qsched_owner_none, qsched_res_none) cell_res(i) = qsched_addres(sched, qsched_owner_none, qsched_res_none)
end do end do
do i=1, 1000 do i=1, 100
data(0) = i data(0) = i
temp = qsched_addtask(sched, type_self, 0, C_LOC(data(0)), int(c_sizeof(type_self), C_INT), 1) temp = qsched_addtask(sched, type_self, 0, C_LOC(data(0)), int(c_sizeof(type_self), C_INT), 1)
call qsched_addlock(sched, temp, cell_res(i)) call qsched_addlock(sched, temp, cell_res(i))
do j=i+1, 1000 do j=i+1, 100
data(1) = j data(1) = j
temp = qsched_addtask(sched, type_pair, 0, C_LOC(data(0)), int(c_sizeof(type_self)*2, C_INT), 1) temp = qsched_addtask(sched, type_pair, 0, C_LOC(data(0)), int(c_sizeof(type_self)*2, C_INT), 1)
call qsched_addlock(sched, temp, cell_res(i)) call qsched_addlock(sched, temp, cell_res(i))
...@@ -226,7 +230,9 @@ end do ...@@ -226,7 +230,9 @@ end do
t_start = omp_get_wtime() t_start = omp_get_wtime()
do i=1,10
call qsched_run(sched, num_threads, runner_func) call qsched_run(sched, num_threads, runner_func)
end do
t_total = omp_get_wtime() - t_start t_total = omp_get_wtime() - t_start
print *, "Took", t_total print *, "Took", t_total
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment