Skip to content

Commit 4f6aa9f

Browse files
improvements for version 0.2.0
1 parent d1118eb commit 4f6aa9f

File tree

8 files changed

+117
-66
lines changed

8 files changed

+117
-66
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PlatformAware"
22
uuid = "e7c50b67-2c03-471e-9cf2-69e515d86ecf"
33
authors = ["Francisco Heron de Carvalho Junior <heron@dc.ufc.br> and contributors"]
4-
version = "0.1.0"
4+
version = "0.2.0"
55

66
[deps]
77
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

src/awareness.jl

Lines changed: 90 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ global processor_dict = merge(processor_dict_amd, processor_dict_intel)
4040
global accelerator_dict = merge(accelerator_dict_intel, accelerator_dict_amd, accelerator_dict_nvidia)
4141

4242
function get_info_dict(idtype)
43-
command = `sudo lshw -xml -C $idtype`
43+
command = `sudo lshw -xml -quiet -C $idtype`
4444
xmlinfo = read(command, String)
4545
xml_dict(xmlinfo)
4646
end
@@ -400,11 +400,40 @@ end
400400
end
401401
=#
402402

403+
function collectProcessorFeaturesDefault()
404+
405+
processor_features = Dict()
406+
407+
processor_features["processor_count"] = 1
408+
processor_features["processor_core_count"] = 1
409+
processor_features["processor_core_threads_count"] = 1
410+
processor_features["processor_core_clock"] = "unset"
411+
processor_features["processor_simd"] = "unset"
412+
processor_features["processor_core_L1_size"] = "unset"
413+
processor_features["processor_core_L2_size"] = "unset"
414+
processor_features["processor_L3_size"] = "unset"
415+
processor_features["processor_manufacturer"] = "unset"
416+
processor_features["processor_tdp"] = "unset"
417+
processor_features["processor"] = "unset"
418+
419+
return processor_features
420+
421+
end
422+
403423
# using CpuId (safe)
404424

405425
function identifyProcessor()
406-
407-
collectProcessorFeatures_CpuId()
426+
try
427+
processor_features = collectProcessorFeatures_CpuId()
428+
println(stderr, "ok")
429+
return processor_features
430+
catch error
431+
println(stderr, "fail.")
432+
println(stderr, "=> Error: detecting processor features failed. Using default features.")
433+
println(stderr, " You can setup processor features manually.")
434+
println(stderr, error)
435+
return collectProcessorFeaturesDefault()
436+
end
408437

409438
#=
410439
l = Vector()
@@ -464,13 +493,40 @@ function collectAcceleratorFeatures(l)
464493
return i == 2 ? accelerator_features["1"] : accelerator_features
465494
end
466495

496+
function collectAcceleratorFeaturesDefault()
497+
498+
default_features = Dict()
499+
500+
default_features["accelerator_count"] = 0
501+
default_features["accelerator"] = "unset"
502+
default_features["accelerator_type"] = "unset"
503+
default_features["accelerator_manufacturer"] = "unset"
504+
default_features["accelerator_api"] = "unset"
505+
default_features["accelerator_architecture"] = "unset"
506+
default_features["accelerator_memorysize"] = "unset"
507+
default_features["accelerator_tdp"] = "unset"
508+
509+
return default_features
510+
end
511+
467512
function identifyAccelerator()
468-
l = Vector()
469-
for d in identifyComponent("display")
470-
push!(l,d["vendor"] * " " * d["product"])
471-
end
513+
try
514+
515+
l = Vector()
516+
for d in identifyComponent("display")
517+
push!(l,d["vendor"] * " " * d["product"])
518+
end
472519

473-
collectAcceleratorFeatures(l)
520+
accelerator_features = collectAcceleratorFeatures(l)
521+
println(stderr, "ok")
522+
return accelerator_features
523+
catch error
524+
println(stderr, "fail.")
525+
println(stderr, "=> Error: detecting accelerator features failed. Using default features.")
526+
println(stderr, " You can setup accelerator features manually.")
527+
println(stderr, error)
528+
return collectAcceleratorFeaturesDefault()
529+
end
474530
end
475531

476532
#=
@@ -580,11 +636,15 @@ function identifyMemory()
580636
end
581637
end
582638
end
583-
584-
return collectMemoryFeatures(d1)
639+
640+
memory_features = collectMemoryFeatures(d1)
641+
println(stderr, "ok")
642+
return memory_features
585643

586644
catch error
587-
println(stderr, "Error fetching memory info. Loading default values.")
645+
println(stderr, "fail.")
646+
println(stderr, "=> Error: detecting primary memory features failed. Using default features.")
647+
println(stderr, " You can setup primary memory features manually.")
588648
println(stderr,error)
589649
return collectMemoryFeaturesDefault()
590650
end
@@ -638,7 +698,9 @@ function identifyStorage()
638698
end
639699
end
640700
catch error
641-
println(stderr, "Error fetching storage info. Loading default values.")
701+
println(stderr, "fail.")
702+
println(stderr, "=> Error: detection of storage features failed. Using default features.")
703+
println(stderr, " You can setup storage features manually.")
642704
println(stderr, error)
643705

644706
# default
@@ -656,7 +718,9 @@ end
656718
# TODO
657719
function identityInterconnection()
658720

659-
println("NOTE: The identification of interconnection features is not yet implemented. Using defaults.")
721+
println(stderr, "fail.")
722+
println(stderr, "=> Note: detection of interconnection features (cluster computing) not yet implemented. Using default features. You can setup manually.")
723+
println(stderr, " You can setup interconnection features manually.")
660724

661725
interconnection_features = Dict()
662726

@@ -673,14 +737,16 @@ end
673737
# TODO
674738
function identifyNode()
675739

676-
println("NOTE: The identification of node features is not yet implemented. Using defaults.")
740+
println(stderr, "fail.")
741+
println(stderr, "=> Note: detection of node features (cluster and cloud computing) not yet implemented. Using default features.")
742+
println(stderr, " You can setup node features manually.")
677743

678744
interconnection_features = Dict()
679745

680746
interconnection_features["node_count"] = 1
681747
interconnection_features["node_provider"] = "OnPremise"
682748
interconnection_features["node_virtual"] = "No"
683-
interconnection_features["node_virtual"] = "Yes"
749+
interconnection_features["node_dedicated"] = "No"
684750
interconnection_features["node_machinefamily"] = "unset"
685751
interconnection_features["node_machinetype"] = "unset"
686752
interconnection_features["node_machinesize"] = "unset"
@@ -716,12 +782,12 @@ end
716782

717783
function setup()
718784

719-
print("indentifying node... "); node_features = identifyNode(); println(stderr, "ok")
720-
print("indentifying processor... "); processor_features = identifyProcessor(); println(stderr, "ok")
721-
print("indentifying accelerator... "); accelerator_features = identifyAccelerator(); println(stderr, "ok")
722-
print("indentifying memory... "); memory_features = identifyMemory(); println(stderr, "ok")
723-
print("indentifying storage... "); storage_features = identifyStorage(); println(stderr, "ok")
724-
print("indentifying interconnection... "); interconnection_features = identityInterconnection(); println(stderr, "ok")
785+
print("identifying node... "); node_features = identifyNode()
786+
print("identifying processor... "); processor_features = identifyProcessor()
787+
print("identifying accelerator... "); accelerator_features = identifyAccelerator()
788+
print("identifying memory... "); memory_features = identifyMemory()
789+
print("identifying storage... "); storage_features = identifyStorage()
790+
print("identifying interconnection... "); interconnection_features = identityInterconnection()
725791

726792
platform_features = Dict()
727793

@@ -749,12 +815,12 @@ function setup()
749815
println("Platform.toml will be searched in the following locations:")
750816
println(" 1) A file path pointed by a PLATFORM_DESCRIPTION environment variable;")
751817
println(" 2) The current directory;")
752-
println(" 3) The /etc/conf directory.")
818+
println(" 3) The /etc directory.")
753819
else
754820
TOML.print(stdout, platform_features)
755821
println(stderr)
756-
println(stderr, "Platform description file already exists in the current folder (Platform.toml)")
757-
println(stderr, "You must erase or move it before to create a new one.")
822+
println(stderr, "Platform description file already exists in the current folder (Platform.toml).")
823+
println(stderr, "You must delete or move it before creating a new one.")
758824
end
759825

760826
end

src/features.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ function readPlatormDescription()
8686
contents
8787
catch
8888
println(stderr,"The platform description file (Platform.toml) was not found.")
89-
println(stderr,"Using default platform settings (calling only default kernels).")
90-
println(stderr,"A Platform.toml file may be created by calling PlatformAware.setup(). Do it !")
89+
println(stderr,"Using default platform features (calling default kernels).")
90+
println(stderr,"A Platform.toml file may be created by calling PlatformAware.setup()")
9191

9292
io = joinpath(artifact"default_platform_description", "DefaultPlatform.toml")
93-
contents = read(io,String)
94-
contents
93+
read(io,String)
9594
end
9695
end
9796

src/platforms/general.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ abstract type MachineSize end
2424

2525
abstract type Locale end
2626

27-
2827
# manufacturer
2928

3029
abstract type Manufacturer end
@@ -54,7 +53,6 @@ abstract type FPGA <: AcceleratorType end
5453

5554
abstract type MIC <: AcceleratorType end
5655

57-
5856
#interconnection
5957
abstract type InterconnectionTopology end
6058
abstract type Interconnection end
@@ -64,8 +62,6 @@ abstract type Interconnection end
6462
abstract type StorageType end
6563
abstract type StorageInterface end
6664

67-
68-
6965
# memory system
7066

7167
abstract type MemoryType end

src/platforms/nvidia/db-accelerators.NVIDIA.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ NVIDIA;Tesla,A30,NVIDIATesla_A30,GPU,NVIDIA,CUDA_8_0,Ampere,24G,165,1,GA100
4545
NVIDIA;Tesla,A2,NVIDIATesla_A2,GPU,NVIDIA,CUDA_8_6,Ampere,24G,60,1,GA107
4646
NVIDIA;Tesla,H100,NVIDIATesla_H100,GPU,NVIDIA,CUDA_9_0,Hopper,80G,350,1,GH100
4747
NVIDIA;Tesla,H100,NVIDIATesla_H100,GPU,NVIDIA,CUDA_8_0,Hopper,80G,700,1,GH100
48-
NVIDIA;GeForce,940MX,NVIDIAGeForce_940MX,GPU,NVIDIA,CUDA_5_0,Maxwell,4G,23,1,GM108M
48+
NVIDIA;GeForce,940MX,NVIDIAGeForce_940MX,GPU,NVIDIA,CUDA_5_0,Maxwell,4G,23,1,GM108M

src/platforms/xilinx/xilinx.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44

55
abstract type Xilinx <: Manufacturer end; export Xilinx
66

7-
abstract type UltrascalePlus_HBM_FPGA <: AcceleratorType end; export UltrascalePlus_HBM_FPGA
7+
abstract type UltrascalePlus_HBM_FPGA <: AcceleratorType end; export UltrascalePlus_HBM_FPGA
8+
9+
#TODO

src/quantifiers/atleast.jl

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,4 @@ abstract type AtLeast512E <: AtLeast256E end # 2^69
136136

137137
# ...
138138

139-
abstract type AtLeastInf <: AtLeast512E end #
140-
141-
142-
143-
144-
145-
146-
147-
#=
148-
quantifiers = Integer[]
149-
150-
function AtLeast(n::Integer)
151-
idx = findfirst(x -> x > n, quantifiers)
152-
if (isnothing(idx))
153-
idx = size(l) + 1
154-
push!(quantifiers,n)
155-
elseif
156-
splice!(quantifiers,idx,[n,quantifiers[idx]])
157-
end
158-
if (idx-1 > 0)
159-
super_n = quantifiers[idx-1]
160-
161-
eval(Meta.parse)
162-
end
163-
=#
139+
abstract type AtLeastInf <: AtLeast512E end #

test/basics.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# specify platform-aware implementations
2828
@platform aware function kernel({accelerator_count::(@atleast 1)},
2929
x,y,args...; z=1, kwargs...)
30-
println(z,": kernel for 1 accelerators")
30+
println(z,": kernel for 1 accelerators of unspecified kind")
3131
end
3232
@platform aware function kernel({accelerator_count::(@atleast 1),
3333
accelerator_manufacturer::NVIDIA},
@@ -37,13 +37,13 @@
3737
@platform aware function kernel({node_count::(@atleast 32),
3838
processor::IntelCore_i7_7500U},
3939
x,y,args...; z=3, kwargs...)
40-
println(z,": kernel for 1 NVIDIA accelerators")
40+
println(z,": kernel optimized to the features of clusters with at least 32 nodes with Intel(R) Core(TM) i7-7500U processors")
4141
end
4242
@platform aware function kernel({accelerator_count::(@just 4),
4343
accelerator_manufacturer::NVIDIA,
4444
accelerator_architecture::Turing},
4545
x,y,args...; z=4, kwargs...)
46-
println(z,": kernel for 4 accelerators of NVIDIA's Turing architecture")
46+
println(z,": kernel for exactly 4 accelerators of NVIDIA's Turing architecture")
4747
end
4848
@platform aware function kernel({node_count::(@between 8 16),
4949
node_memory_size::(@atleast 16G),
@@ -53,16 +53,28 @@
5353
interconnection_bandwidth::(@atleast 128G)
5454
},
5555
x,y,args...; z=5, kwargs...)
56-
println(z,": kernel for a cluster of 8-16 nodes having at least 2 processors each wih at least 8 cores ...")
56+
println(z,": kernel tuned for a cluster of 8 to 16 nodes having at least 2 processors with at least 8 cores each,")
57+
println(z,": connected through an intereconnection having at most 32us latency and at least 128Gbs bandwidth.")
5758
end
58-
@platform aware function kernel({accelerator_type::FPGA,
59+
@platform aware function kernel({accelerator_count::(@atleast 1),
60+
accelerator_type::FPGA,
5961
accelerator_memorysize::(@atleast 16G),
6062
processor_simd::AVX512,
6163
node_memory_size::(@atleast 256G)
6264
},
6365
x,y,args...; z=6, kwargs...)
64-
println(z,": kernel for a UltrascalePlus+ HBM FPGA")
66+
println(z,": kernel for a platform equipped with a FPGA accelerator with at least 16GB of memory,")
67+
println(z,": a processor with AVX512 SIMD support, and 256GB of primary memory.")
6568
end
6669

6770
kernel(0,1,2,3;z=10,kwargs=0)
71+
72+
PlatformAware.setplatform!(:accelerator_count, @just 1)
73+
PlatformAware.setplatform!(:accelerator_manufacturer, NVIDIA)
74+
75+
@platform default function kernel(x,y,args...; z=0, kwargs...)
76+
println(z,": default implementation of kernel_example:")
77+
end
78+
79+
kernel(1,2,3,4;z=11,kwargs=0)
6880
end

0 commit comments

Comments
 (0)