Skip to content

Commit 359063c

Browse files
authored
Merge pull request #171 from bonachea/more-teams
Add more team support
2 parents 52d1324 + 341e91a commit 359063c

File tree

10 files changed

+185
-52
lines changed

10 files changed

+185
-52
lines changed

docs/implementation-status.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ in the following sections.
5555
| Procedure | Status | Notes |
5656
|-----------|--------|-------|
5757
| `prif_num_images` | **YES** | |
58-
| `prif_num_images_with_team`, `prif_num_images_with_team_number` | no | |
59-
| `prif_this_image_no_coarray` | *partial* | team argument is ignored |
58+
| `prif_num_images_with_team` | **YES** | |
59+
| `prif_num_images_with_team_number` | no | |
60+
| `prif_this_image_no_coarray` | **YES** | |
6061
| `prif_this_image_with_coarray`, `prif_this_image_with_dim` | no | |
6162
| `prif_failed_images` | no | |
6263
| `prif_stopped_images` | no | |
@@ -183,13 +184,13 @@ in the following sections.
183184
---
184185

185186
## Teams
186-
### Support = partial (No support for `prif_get_team` and `prif_team_number`)
187+
### Support = **YES**
187188

188189
| Procedure | Status | Notes |
189190
|-----------|--------|-------|
190191
| `prif_form_team` | **YES** | |
191-
| `prif_get_team` | no | |
192-
| `prif_team_number` | no | |
192+
| `prif_get_team` | **YES** | |
193+
| `prif_team_number` | **YES** | |
193194
| `prif_change_team` | **YES** | |
194195
| `prif_end_team` | **YES** | |
195196

@@ -246,4 +247,4 @@ in the following sections.
246247
| `prif_atomic_ref_logical_indirect` | no | |
247248
-->
248249

249-
---
250+
---

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e # exit on error
44

src/caffeine/allocation_s.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
type(prif_coarray_descriptor) :: unused
2525
type(prif_coarray_descriptor), pointer :: unused2(:)
2626

27-
me = caf_this_image(current_team%info%gex_team)
27+
me = current_team%info%this_image
2828
if (caf_have_child_teams()) then
2929
! Free the child team space to make sure we have space to allocate the coarray
3030
if (me == 1) then
@@ -119,13 +119,13 @@
119119
! end do
120120
do i = 1, num_handles
121121
call remove_from_team_list(coarray_handles(i))
122-
if (caf_this_image(current_team%info%gex_team) == 1) &
122+
if (current_team%info%this_image == 1) &
123123
call caf_deallocate(current_team%info%heap_mspace, c_loc(coarray_handles(i)%info))
124124
end do
125125
if (present(stat)) stat = 0
126126
if (caf_have_child_teams()) then
127127
! reclaim any free space possible for the child teams to use
128-
if (caf_this_image(current_team%info%gex_team) == 1) then
128+
if (current_team%info%this_image == 1) then
129129
call caf_deallocate(current_team%info%heap_mspace, current_team%info%child_heap_info%allocated_memory)
130130
end if
131131
call caf_establish_child_heap

src/caffeine/caffeine.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,23 @@ typedef void(*final_func_ptr)(void*, size_t) ;
2828
typedef uint8_t byte;
2929

3030
#if __GNUC__ >= 12
31-
const int float_Complex_workaround = CFI_type_float_Complex;
32-
const int double_Complex_workaround = CFI_type_double_Complex;
31+
#define float_Complex_workaround CFI_type_float_Complex
32+
#define double_Complex_workaround CFI_type_double_Complex
3333
#else
34-
const int float_Complex_workaround = 2052;
35-
const int double_Complex_workaround =4100;
34+
#define float_Complex_workaround 2052
35+
#define double_Complex_workaround 4100
3636
#endif
3737

38-
int caf_this_image(gex_TM_t team)
38+
// ---------------------------------------------------
39+
int caf_this_image(gex_TM_t gex_team)
3940
{
40-
return gex_TM_QueryRank(team) + 1;
41+
return gex_TM_QueryRank(gex_team) + 1;
4142
}
42-
43+
int caf_num_images(gex_TM_t gex_team)
44+
{
45+
return gex_TM_QuerySize(gex_team);
46+
}
47+
// ---------------------------------------------------
4348
// NOTE: gex_TM_T is a typedef to a C pointer, so the `gex_TM_t* initial_team` arg in the C signature matches the BIND(C) interface of an `intent(out)` arg of type `c_ptr` for the same argument
4449
void caf_caffeinate(
4550
mspace* symmetric_heap,
@@ -94,11 +99,6 @@ void caf_decaffeinate(int exit_code)
9499
gasnet_exit(exit_code);
95100
}
96101

97-
int caf_num_images(gex_TM_t team)
98-
{
99-
return gex_TM_QuerySize(team);
100-
}
101-
102102
void* caf_allocate(mspace heap, size_t bytes)
103103
{
104104
void* allocated_space = mspace_memalign(heap, 8, bytes);

src/caffeine/image_queries_s.f90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@
77
contains
88

99
module procedure prif_num_images
10-
num_images = caf_num_images(current_team%info%gex_team)
10+
num_images = current_team%info%num_images
1111
end procedure
1212

1313
module procedure prif_num_images_with_team
14-
call unimplemented("prif_num_images_with_team")
14+
num_images = team%info%num_images
1515
end procedure
1616

1717
module procedure prif_num_images_with_team_number
1818
call unimplemented("prif_num_images_with_team_number")
1919
end procedure
2020

2121
module procedure prif_this_image_no_coarray
22-
! TODO: handle optional arg `team`
23-
this_image = caf_this_image(current_team%info%gex_team)
22+
if (present(team)) then
23+
this_image = team%info%this_image
24+
else
25+
this_image = current_team%info%this_image
26+
endif
2427
end procedure
2528

2629
module procedure prif_this_image_with_coarray

src/caffeine/prif_private_s.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ subroutine caf_decaffeinate(exit_code) bind(C)
4242

4343
! _________________ Image enumeration ____________________
4444

45-
function caf_this_image(team) bind(C)
46-
!! int caf_this_image();
45+
function caf_this_image(gex_team) bind(C)
46+
!! int caf_this_image(gex_TM_t gex_team);
4747
import c_ptr, c_int
4848
implicit none
49-
type(c_ptr), value :: team
49+
type(c_ptr), value :: gex_team
5050
integer(c_int) caf_this_image
5151
end function
5252

53-
pure function caf_num_images(team) bind(C)
54-
!! int caf_num_images();
53+
pure function caf_num_images(gex_team) bind(C)
54+
!! int caf_num_images(gex_TM_t gex_team);
5555
import c_ptr, c_int
5656
implicit none
57-
type(c_ptr), value :: team
57+
type(c_ptr), value :: gex_team
5858
integer(c_int) caf_num_images
5959
end function
6060

@@ -270,7 +270,7 @@ pure function optional_value(var) result(c_val)
270270
end function
271271

272272
subroutine caf_establish_child_heap
273-
if (caf_this_image(current_team%info%gex_team) == 1) then
273+
if (current_team%info%this_image == 1) then
274274
call caf_allocate_remaining( &
275275
current_team%info%heap_mspace, &
276276
current_team%info%child_heap_info%allocated_memory, &

src/caffeine/program_startup_s.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
non_symmetric_heap_mspace, &
1818
initial_team%gex_team)
1919
current_team%info => initial_team
20+
initial_team%parent_team => initial_team
21+
initial_team%team_number = -1
22+
initial_team%this_image = caf_this_image(initial_team%gex_team)
23+
initial_team%num_images = caf_num_images(initial_team%gex_team)
2024
prif_init_called_previously = .true.
2125
stat = 0
2226
end if

src/caffeine/teams_s.f90

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,30 @@
7373
allocate(team%info)
7474
team%info%parent_team => current_team%info
7575
call caf_form_team(current_team%info%gex_team, team%info%gex_team, team_number, new_index_)
76+
team%info%team_number = team_number
77+
team%info%this_image = caf_this_image(team%info%gex_team)
78+
team%info%num_images = caf_num_images(team%info%gex_team)
7679
end block
7780
end procedure
7881

7982
module procedure prif_get_team
80-
call unimplemented("prif_get_team")
83+
if (.not. present(level) .or. level == PRIF_CURRENT_TEAM) then
84+
team = current_team
85+
else if (level == PRIF_PARENT_TEAM) then
86+
team = prif_team_type(current_team%info%parent_team)
87+
else if (level == PRIF_INITIAL_TEAM) then
88+
team = prif_team_type(initial_team)
89+
else
90+
call prif_error_stop(.false._c_bool, stop_code_char="prif_get_team: invalid level")
91+
endif
8192
end procedure
8293

8394
module procedure prif_team_number
84-
call unimplemented("prif_team_number")
95+
if (present(team)) then
96+
team_number = team%info%team_number
97+
else
98+
team_number = current_team%info%team_number
99+
endif
85100
end procedure
86101

87102
end submodule

src/prif.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,8 @@ module subroutine prif_atomic_ref_logical_indirect(image_num, atom_remote_ptr, v
10561056
type(c_ptr) :: heap_mspace
10571057
integer(c_intptr_t) :: heap_start
10581058
integer(c_size_t) :: heap_size
1059+
integer(c_int64_t) :: team_number
1060+
integer(c_int) :: this_image, num_images
10591061
type(team_data), pointer :: parent_team => null()
10601062
type(prif_coarray_descriptor), pointer :: coarrays => null()
10611063
type(child_team_info), pointer :: child_heap_info => null()

0 commit comments

Comments
 (0)