forked from swiftlang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libclc: Make all built-ins overloadable
The SPIR spec states that all OpenCL built-in functions should be overloadable and mangled, to ensure consistency. Add the overload attribute to functions which were missing them: work dimensions, memory barriers and fences, and events. Reviewed By: tstellar, jenatali Differential Revision: https://reviews.llvm.org/D82078
- Loading branch information
Showing
41 changed files
with
191 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF void barrier(cl_mem_fence_flags flags) | ||
{ | ||
mem_fence(flags); | ||
__builtin_amdgcn_s_barrier(); | ||
_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) { | ||
mem_fence(flags); | ||
__builtin_amdgcn_s_barrier(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF size_t get_group_id(uint dim) | ||
{ | ||
switch(dim) { | ||
case 0: return __builtin_amdgcn_workgroup_id_x(); | ||
case 1: return __builtin_amdgcn_workgroup_id_y(); | ||
case 2: return __builtin_amdgcn_workgroup_id_z(); | ||
default: return 1; | ||
} | ||
_CLC_DEF _CLC_OVERLOAD size_t get_group_id(uint dim) { | ||
switch (dim) { | ||
case 0: | ||
return __builtin_amdgcn_workgroup_id_x(); | ||
case 1: | ||
return __builtin_amdgcn_workgroup_id_y(); | ||
case 2: | ||
return __builtin_amdgcn_workgroup_id_z(); | ||
default: | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF size_t get_local_id(uint dim) | ||
{ | ||
switch(dim) { | ||
case 0: return __builtin_amdgcn_workitem_id_x(); | ||
case 1: return __builtin_amdgcn_workitem_id_y(); | ||
case 2: return __builtin_amdgcn_workitem_id_z(); | ||
default: return 1; | ||
} | ||
_CLC_DEF _CLC_OVERLOAD size_t get_local_id(uint dim) { | ||
switch (dim) { | ||
case 0: | ||
return __builtin_amdgcn_workitem_id_x(); | ||
case 1: | ||
return __builtin_amdgcn_workitem_id_y(); | ||
case 2: | ||
return __builtin_amdgcn_workitem_id_z(); | ||
default: | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
void wait_group_events(int num_events, event_t *event_list); | ||
_CLC_DECL _CLC_OVERLOAD void wait_group_events(int num_events, | ||
event_t *event_list); |
6 changes: 3 additions & 3 deletions
6
libclc/generic/include/clc/explicit_fence/explicit_memory_fence.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
_CLC_DECL void mem_fence(cl_mem_fence_flags flags); | ||
_CLC_DECL void read_mem_fence(cl_mem_fence_flags flags); | ||
_CLC_DECL void write_mem_fence(cl_mem_fence_flags flags); | ||
_CLC_DECL _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags); | ||
_CLC_DECL _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags); | ||
_CLC_DECL _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL void barrier(cl_mem_fence_flags flags); | ||
_CLC_DECL _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_global_id(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_global_id(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_global_offset(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_global_offset(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_global_size(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_global_size(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_group_id(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_group_id(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_local_id(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_local_id(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_local_size(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_local_size(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL size_t get_num_groups(uint dim); | ||
_CLC_DECL _CLC_OVERLOAD size_t get_num_groups(uint dim); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_CLC_DECL uint get_work_dim(void); | ||
_CLC_DECL _CLC_OVERLOAD uint get_work_dim(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF void wait_group_events(int num_events, event_t *event_list) { | ||
_CLC_DEF _CLC_OVERLOAD void wait_group_events(int num_events, | ||
event_t *event_list) { | ||
barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF size_t get_global_id(uint dim) { | ||
_CLC_DEF _CLC_OVERLOAD size_t get_global_id(uint dim) { | ||
return get_group_id(dim) * get_local_size(dim) + get_local_id(dim) + get_global_offset(dim); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF size_t get_global_size(uint dim) { | ||
_CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { | ||
return get_num_groups(dim)*get_local_size(dim); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF void mem_fence(cl_mem_fence_flags flags) { | ||
if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE)) | ||
__nvvm_membar_cta(); | ||
_CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) { | ||
if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE)) | ||
__nvvm_membar_cta(); | ||
} | ||
|
||
// We do not have separate mechanism for read and write fences. | ||
_CLC_DEF void read_mem_fence(cl_mem_fence_flags flags) { | ||
_CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) { | ||
mem_fence(flags); | ||
} | ||
|
||
_CLC_DEF void write_mem_fence(cl_mem_fence_flags flags) { | ||
_CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) { | ||
mem_fence(flags); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF void barrier(cl_mem_fence_flags flags) { | ||
_CLC_DEF _CLC_OVERLOAD void barrier(cl_mem_fence_flags flags) { | ||
__syncthreads(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include <clc/clc.h> | ||
|
||
_CLC_DEF size_t get_global_id(uint dim) { | ||
_CLC_DEF _CLC_OVERLOAD size_t get_global_id(uint dim) { | ||
return get_group_id(dim) * get_local_size(dim) + get_local_id(dim); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.